简体   繁体   English

如何修复 websocket 错误:WebSocket 握手期间出错:net::ERR_CONNECTION_RESET

[英]How to fix websocket error: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

I want to create a web socket using Python and JavaScript, but I get the following error.我想使用 Python 和 JavaScript 创建一个网络套接字,但出现以下错误。 thank you谢谢你

WebSocket connection to 'ws://localhost:1386/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED WebSocket 连接到“ws://localhost:1386/”失败:连接建立错误:net::ERR_CONNECTION_REFUSED

Python Code:蟒蛇代码:

from socket import *
s = socket(AF_INET, SOCK_STREAM)
s.bind(("localhost", 1386))
s.listen(5)
client, addr = s.accept()
print("connected to "+ str(addr))
client.sendall("hi. im server".encode())
client.close()

JavaScript - HTML Code JavaScript - HTML 代码

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <script>
        var socket = new WebSocket('ws://localhost:1386');
    </script>
</head>
<body>

</body>
</html>

Error during WebSocket handshake: net::ERR_CONNECTION_RESET WebSocket 握手期间出错:net::ERR_CONNECTION_RESET

Try to change ' ws ://localhost:1386' to ' wss ://localhost:1386'尝试将 ' ws ://localhost:1386' 更改为 ' wss ://localhost:1386'

ws >>> wss ws >>> wss

暂无
暂无

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

相关问题 WebSocket握手错误网:: ERR_CONNECTION_RESET - WebSocket handshake error net::ERR_CONNECTION_RESET Django 通道失败:WebSocket 握手期间出错:net::ERR_CONNECTION_RESET - Django Channels failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET Javascript 套接字(失败:WebSocket 握手期间出错:net::ERR_CONNECTION_RESET) - Javascript Sockets (failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET) 如何修复错误POST ... net :: ERR_CONNECTION_RESET - How fix error POST … net::ERR_CONNECTION_RESET WebSocket 连接失败。 WebSocket 握手期间出错 - socketjs - WebSocket connection failed. Error during WebSocket handshake - socketjs Http请求-&gt; net_error = -101(ERR_CONNECTION_RESET) - Http request --> net_error = -101 (ERR_CONNECTION_RESET) 与&#39;ws:// ... / websocket&#39;的Meteor WebSocket连接失败:WebSocket握手期间出错:意外的响应代码:400 - Meteor WebSocket connection to 'ws://…/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400 与&#39;wss:// localhost:44300 / Home / websocketcon&#39;的WebSocket连接失败:WebSocket握手期间出错:意外响应代码:404 - WebSocket connection to 'wss://localhost:44300/Home/websocketcon' failed: Error during WebSocket handshake: Unexpected response code: 404 WebSocket 连接到...失败:WebSocket 握手期间出错:意外响应代码:200 - WebSocket connection to ... failed: Error during WebSocket handshake: Unexpected response code: 200 WebSocket连接到 <url> 失败:WebSocket握手期间出错:意外的响应代码:404 - WebSocket connection to <url> failed: Error during WebSocket handshake: Unexpected response code: 404
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM