Closed icoco closed 1 year ago
Please show what the server sends in response.
server part was create by python , the code slice like bellow: ` .....
# https://datatracker.ietf.org/doc/html/rfc6455#page-7
accept_header = hashlib.sha1(
(headers['sec-websocket-key'] + cls._HANDSHAKE_GUID).encode()).digest()
accept_header = base64.b64encode(accept_header)
return Response(status=101, headers={
'Upgrade': 'websocket',
'Connection': 'Upgrade',
'Sec-WebSocket-Accept': accept_header,
})`
console log message: <Response 0 bytes [101 SWITCHING PROTOCOLS]>
I am not sure if need client do some config then can handle the SWITCHING case?
Tungstenite supports all aspects of RFC6455 including protocol switching which is indeed mandatory. The error looks more like incorrect header formatting at server side. Please double check the server's response, especially its HTTP version field.
Unfortunately, the posted Python snippet is incomplete and poorly formatted - this does not enable us to help you with your particular case. We don't even know which version of the tokio-tungstenite
you use, which features are configured, we don't have a simple self-contained reproducible example.
I've just noticed from your original post: "Runningtarget/debug/examples/autobahn-client". So you are not even running tokio-tungstenite
, you're running the autobahn client example? I'm not quite sure what are you trying to achieve, but I very much doubt that there there is some sort of misbehavior from tokio-tungstenite
. Moreover, it's easy to see from the logs that you're running a modified version of the autobahn client, because our official example uses a different port.
seem the lib does not support the feature? or maybe miss some config while make ws connect, I face the problem bellow:
Running
target/debug/examples/autobahn-client[2023-03-09T16:27:29Z TRACE tungstenite::handshake::client] Request: "GET /websocket HTTP/1.1\r\nHost: localhost:8020\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: MtGxf2qvBv2BpXsfV2656A==\r\n\r\n" [2023-03-09T16:27:29Z TRACE tungstenite::handshake::client] Client handshake initiated. [2023-03-09T16:27:29Z TRACE tungstenite::handshake::machine] Doing handshake round. [2023-03-09T16:27:29Z TRACE tungstenite::handshake::machine] Doing handshake round. [2023-03-09T16:27:29Z TRACE tungstenite::handshake::machine] Doing handshake round. [2023-03-09T16:28:14Z TRACE tungstenite::handshake::machine] Doing handshake round. thread 'main' panicked at 'Error get_websocket: Protocol(HttparseError(Version))',
not sure how to solve this problem, anyone help, thanks