And how do you close the connection ?

The connection closes automatically if the peer gets disconnected from your server, to close a connection manually you either send a close message to the peer to trigger a close function, or if the peer wants to disconnect it should call that close function on its side

The close function is defined in the client side and how it’s implemented depends on what kind of the client is javascript, Android or, iOS, etc..

I’ll post an article showing how to handle websockets on client side in javascript as soon as I can.

Like what you read? Give Mohyaddin Alaoddin a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.