简体   繁体   English

连接建立错误:尝试建立并连接到Websocket服务器时,抛出net :: ERR_SSL_PROTOCOL_ERROR

[英]Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server

As is shown in the title, I am getting an error while establishing and connecting to a server. 如标题所示,建立和连接服务器时出现错误。 I am using a npm library called simple-websocket in order to achieve this. 我正在使用一个名为simple-websocket的npm库来实现此目的。

On my server side I am using node and for my front end I am bundling the node modules using browserify. 在服务器端,我正在使用节点,而对于前端,我正在使用browserify捆绑节点模块。 I have already tried changing the port and have searched for a fix with no results. 我已经尝试过更改端口,并搜索了没有结果的修复程序。

This is my node code: 这是我的节点代码:

const Server = require('simple-websocket/server')

const server = new Server({port: 8181})

new Promise((resolve, reject) => {
  server.on('connection', function(socket, request) {
    resolve({socket, request})
  })
}).then(data => {
  console.log(data)
})

This is my web code: 这是我的网络代码:

const Socket =  require('simple-websocket')

exports.test = function() {
  const socket = new Socket('wss://localhost:8181')

  socket.on('connect', function() {
    console.log('yes')
  })
}

And This is the full error: 这是完整的错误:

WebSocket connection to 'wss://localhost:8181/' failed: Error in connection 
establishment: net::ERR_SSL_PROTOCOL_ERROR

bundle.js:6106 Uncaught Error: connection error to wss://localhost:8181
at WebSocket.Socket.self._ws.onerror (bundle.js:6106)
Socket.self._ws.onerror @ bundle.js:6106
error (async)
Socket @ bundle.js:6105
exports.test @ bundle.js:2841
9../middleware-comms/Listen @ bundle.js:2836
o @ bundle.js:1
r @ bundle.js:1
(anonymous) @ bundle.js:1

In case it is useful, Here is the browserified code: http://www.filedropper.com/bundle_2 如果有用,请使用以下浏览器代码: http : //www.filedropper.com/bundle_2

The simple-websocket/server instance you're creating isn't listening for encrypted/wss/ssl connections, it is listening for standard websocket connections. 您创建的simple-websocket/server实例不是在监听加密的/ wss / ssl连接,而是在监听标准的websocket连接。 You should be trying to connect to it with ws://localhost:8181 (not wss://... ). 您应该尝试使用ws://localhost:8181 (而不是wss://... )连接到它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP Websocket 错误:net::ERR_SSL_PROTOCOL_ERROR 使用 cloudflare - PHP Websocket ERROR: net::ERR_SSL_PROTOCOL_ERROR using cloudflare socket.io 错误网络::ERR_SSL_PROTOCOL_ERROR - socket.io error net::ERR_SSL_PROTOCOL_ERROR 如何处理net :: ERR_SSL_PROTOCOL_ERROR? - How to deal with net::ERR_SSL_PROTOCOL_ERROR? 无法连接到安全 socket.io 服务器:ERR_SSL_PROTOCOL_ERROR - Cannot connect to secure socket.io server : ERR_SSL_PROTOCOL_ERROR 访问不同端口时,js fetch 失败并出现 net::ERR_SSL_PROTOCOL_ERROR - js fetch fails with net::ERR_SSL_PROTOCOL_ERROR when accessing different ports Wordpress - 错误 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL 协议错误 - Wordpress - Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error chrome 扩展 WebSocket 连接到“ws://localhost:9090/”失败:连接建立错误:net::ERR_CONNECTION_REFUSED - chrome extension WebSocket connection to 'ws://localhost:9090/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED 跨域请求的间歇性 ERR_SSL_PROTOCOL_ERROR 错误 - Intermittent ERR_SSL_PROTOCOL_ERROR error for cross domain request WebSocket 连接到“wss://ip:8080/”失败:连接建立错误:net::ERR_CONNECTION_REFUSED - WebSocket connection to 'wss://ip:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED WebSocket 连接失败:连接建立时出错:.net::ERR_CONNECTION_REFUSED - WebSocket connection failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM