Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to monitor a web socket connection? [closed]

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.

  • subscribe()
  • unsubscribe()
  • onreceive()
  • send()
  • connect()
like image 824
Neo Avatar asked Jun 29 '11 13:06

Neo


People also ask

How do I know if a WebSocket is closed?

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.

When WebSocket connection is closed?

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.

How do I open a closed WebSocket connection?

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.


1 Answers

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:

  1. Logging WebSocket Frames using Chrome Developer Tools, Net-internals and Wireshark (TOTD #184)
  2. And a book chapter listed by Springer (PDF) The book seems to be The Definitive Guide to HTML5 WebSocket.
like image 135
Borislav Sabev Avatar answered Oct 06 '22 01:10

Borislav Sabev