Repository navigation
How to tell who disconnect ws? #1643
|
Thank you for your project! I want to know how to tell who disconnect ws in In Thank you. |
Replies: 10 comments 1 reply
|
Code 1006 is reserved for the library. It cannot be sent over the wire so getting that code in close handler means it originated from the library itself. |
|
Thank you for your reply! It means if I got a Thank you! |
|
Yes and you can also see this if you look at WireShark or similar tcpdump |
|
Thank you! |
|
I got a How to prove this?(ws is closed by client side fire wall or VPN) Thank you! |
|
Here is the back trace for Specially, in Is this a reasonable flow? Looking forward for your reply. Thank you! |
|
Ah, okay let me clarify: 1006 1006 is a reserved value and MUST NOT be set as a status code in a So in your case you get TCP FIN either from the OS or the client (no way to tell) and that causes the lib to emit 1006. Essentially you have a broken connection or a broken client in some way - the client should not send TCP FIN before a WebSocket Close frame. So in your case it can be anything. Hard to tell. But any reliable app shouldn't care - from its perspective you just need to handle it. For debugging - now that's up to you. |
|
Yes, you're right. The websocket framework used by the C++ client is mongoose. This C++ client does not wait for a response after excuting the close connection operation. However, I tested with the python client (which calls the websockets package) and found that the python client will wait for the server's response after closing the connection. So, I need NOT to care about this Looking for your reply! |
|
Probably more likely that you are using mongoose wrong - it looks like a well used client and very low level. So wouldn't be a shock if you just haven't got the shutdown procedure correct. In any case, a server should handle all cases correctly. |
|
Do you mean I'm not using the server or the client correctly? But whether it is uwebsocket or mongoose, I use the example code for testing. As you said, "In any case, a server should handle all cases correctly.", how can I handle this |
Code 1006 is reserved for the library. It cannot be sent over the wire so getting that code in close handler means it originated from the library itself.