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. |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply! It means if I got a Thank you! |
Beta Was this translation helpful? Give feedback.
-
Yes and you can also see this if you look at WireShark or similar tcpdump |
Beta Was this translation helpful? Give feedback.
-
Thank you! |
Beta Was this translation helpful? Give feedback.
-
I got a How to prove this?(ws is closed by client side fire wall or VPN) Thank you! |
Beta Was this translation helpful? Give feedback.
-
Here is the back trace for
Specially, in Is this a reasonable flow? Looking forward for your reply. Thank you! |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
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.