Closed chj113 closed 4 months ago
The server is closing the connection, as shown here in the log:
DEBUG:websockets.client:< CLOSE 1002 (protocol error) [2 bytes]
Maybe the server logs say why it's closing the connection?
No error found in server logs.Other stomp clients like stompjs connect to the same server work well. After I turned off the server's heartbeat, this error no longer exists.but the connection closed after a few minites.
The server is closing the connection, as shown here in the log:
DEBUG:websockets.client:< CLOSE 1002 (protocol error) [2 bytes]
Maybe the server logs say why it's closing the connection?
server log like this: LoggingWebSocketHandlerDecorator closed with CloseStatus[code=1002, reason=null] It looks like a protocol error. https://stackoverflow.com/questions/65269411/websocket-closes-with-protocol-error-1002 Can y give me a demo that websockets works over stomp?thanks...
Try adding ping_interval=None
instead of ping_interval=5
. If that works, then the problem could be that the server attempts to UTF-8-decode the payload of pings, which is incorrect — nothing says that ping payloads must be valid UTF-8 — but I've seen that before.
The logs that you posted don't corroborate this theory fully. The first ping payload becomes invalid UTF-8 in the fourth byte, while the second ping payload is invalid at the first byte. Still, the fact that the error happens at a different point might cause different behavior.
>>> b"\x7e\x7e\x1d\x92".decode()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 3: invalid start byte
>>> b"\xc4\xf5\xce\x9a".decode()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte
Can y give me a demo that websockets works over stomp?
I'm not familiar with STOMP. What I see in the logs is a completely valid WebSocket session. From the perspective of the WebSocket RFC, websockets does the right thing. Really the question is "what does the server dislike?"
@aaugustin Thanks for your help! When I modified it to the following code, it started working properly. I hope it will be helpful to others. heart-beat:4000,10000 -> heart-beat:0,0
connect_frame = (
'CONNECT\n'
'accept-version:1.2,1.1,1.0\n'
'heart-beat:0,0\n'
f'Authorization:{token}\n'
'\n'
'\x00'
)
I connected springboot websocket server by python client(javascript client stomp.js on chrome is ok), but receive Session closed ERROR...,I need help,thanks..
python:3.8 websockets:13.0
python log
python code
springboot server: