WebSocket 连接到“ws://localhost:9090/"失败:连接建立错误:net::ERR_CONNECTION_REFUSED [英] WebSocket connection to 'ws://localhost:9090/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
问题描述
我是 WebRTC 和 WebSockets 的新手,正在按照本教程创建 WebRTC 演示项目,但我无法创建 WebSocket 连接.我遵循了项目中提到的相同步骤.他的项目在端口 8080 上运行,他提到了 ws://localhost:9090.我的项目在端口 8081 上运行,但我复制了他的 URL ws://localhost:9090,因为我不知道 9090 的意义,我收到了这个错误,我的服务器是 node.js.我也将本地主机更改为 8081,但随后出现握手错误.
I am new to WebRTC and WebSockets and was following this tutorial to create a WebRTC demo project, but I am unable to create a WebSocket connection. I have followed the same steps as mentioned in the project. His project is running on port 8080 and he mentioned ws://localhost:9090. My project is running on port 8081, but I copied his URL ws://localhost:9090 because I didn't know the significance of 9090 and I received this error and my server is node.js. i changed local host to 8081 as well but then i am getting hand shake error.
WebSocket 连接到ws://localhost:9090/"失败:错误连接建立:net::ERR_CONNECTION_REFUSED.
WebSocket connection to 'ws://localhost:9090/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED.
推荐答案
Chrome 不允许不安全的 websocket (ws) 连接到本地主机(仅 wss,因此您应该为本地 web/websocket 服务器设置 TLS 证书).但是,Firefox 应该也能正常工作.
Chrome doesn't allow unsecure websocket (ws) connections to localhost (only wss, so you should setup a TLS certificate for your local web/websocket server). However the same should work fine with Firefox.
这篇关于WebSocket 连接到“ws://localhost:9090/"失败:连接建立错误:net::ERR_CONNECTION_REFUSED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!