I tried to find a tool to monitor single web socket connection... I didn't find any useful resources. My intention is to read the data that is going through a socket like, what data is passed through these methods.
You can check if a WebSocket is disconnected by doing either of the following: Specifying a function to the WebSocket. onclose event handler property, or; Using addEventListener to listen to the close event.
Close event marks the end of a communication between the server and the client. Closing a connection is possible with the help of onclose event. After marking the end of communication with the help of onclose event, no messages can be further transferred between the server and the client.
Once the original connection has been closed, you need to create a new websocket object with new event listeners: var SERVER = 'ws://localhost:8080' var ws = new WebSocket(SERVER) ws. onmessage = function(e){ console. log('websocket message event:', e) } ws.
just saw this question. Answering for any others that may be wondering on the issue.
As mentioned Wireshark can "inspect" WebSocket frames as described here. However for around an year now, Google Chrome has built in support for this. In Developer Tools, under Network there is a sub-filter for WebSockets. Another nice Chrome feature are the so-called "Net-Internals" thay can really help dive "behind the scenes" in the browser.
Here are some nice articles on how this can all be used together:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With