Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web socket error close codes specific to browser

I am using Websockets in my application for streaming purpose . I am using Jetty in back end for this purpose

On to the onclose call back method i have this

@Override
    public void onClose(int arg0, String arg1) {
        logger.info("In onClose :: " + arg0 + " :: " + arg1);
}

What i observed is that , the error codes are not generic but specific to browser that is

When i use chrome it displays 1006 , if browser is closed using ctrl+w , Clicked on Cross Button , or even user clicked on logout button

but where as in firefox it displays 1001 if browser is closed using ctrl+w , Clicked on Cross Button , or even user clicked on logout button

Now the problem is that i really cannot identify why a disconnect has been happened , because as it being a browser specific ??

please share your views as how to debug in such cases ??


1 Answers

This may help:

https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1

Specifically:

1001 indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page.>

and

1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g., without sending or receiving a Close control frame.

So I am going to guess that you're looking at this from the server standpoint in which case the 1006 would indicate that the chrome endpoint did not behave well and the server reacted to that with the special close code. In your client side I would start debugging it to ensure it makes it into whatever close code is required to get that actual close code of 1001 back to the server. Now you may not be able to get to close logic in all of your scenarios, that is why this close code exists in the first place, but you should at least be able to close the connection cleanly via your own logout button.

like image 54
jesse mcconnell Avatar answered Jun 14 '26 11:06

jesse mcconnell