小编CN1*_*CN1的帖子

与'ws:// localhost:3434 /'的WebSocket连接失败:连接在收到握手响应之前关闭

当使用cmd运行节点server.js并在Web浏览器中启动localhost:3434时,我收到错误:

在Chrome中:

连接在收到握手响应之前关闭.

在Firefox中:

Firefox无法在ws:// localhost:3434 /建立与服务器的连接

你能帮忙吗?

server.js

var http = require('http'),
fs = require('fs');

fs.readFile('../index.html', function (err, html) {
if (err) {
   throw err;
}
http.createServer(function (request, response) {
    response.writeHeader(200, { "Content-Type": "text/html" });
    response.write(html);
    response.end();
}).listen(3434);
});
Run Code Online (Sandbox Code Playgroud)

的index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<script type="text/javascript" src="../../js/adapter.js"></script>-->
<!--<script type="text/javascript" src="../../js/webrtc.js"></script>-->
<title>Simple WebRTC video chat</title>
</head>
<body>
<header>
<video id="localVideo" autoplay="autoplay" muted="muted"        style="width:40%;"></video>
    <video id="remoteVideo" autoplay="autoplay" style="width:40%;"></video>
    <input type="button" id="start" onclick="start(true)" value="Start  Video"; />
</header>
<script>
    var RTCPeerConnection = …
Run Code Online (Sandbox Code Playgroud)

localhost websocket node.js webrtc

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

localhost ×1

node.js ×1

webrtc ×1

websocket ×1