Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In what cases will a websocket close event tell you wasClean is false?

In what cases will a websocket close event tell you wasClean is false? For example:

connection.onclose = function(event) {
   if(!event.wasClean) {
      // whyyyyyyy???
   }
}
like image 222
B T Avatar asked Jun 13 '14 20:06

B T


1 Answers

wasClean property is set to false when the WebSocket connection did not close via the close handshake.
i.e. by not receiving a valid Close frame from the server.

And from documentation: "CloseEvent.wasClean Returns a Boolean that Indicates whether or not the connection was cleanly closed"

like image 51
galbarm Avatar answered Sep 22 '22 04:09

galbarm