Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Websockets?

I want to monitor the websocket traffic (like to see what version of the protocol the client/server is using) for debugging purposes. How would I go about doing this? Wireshark seems too low level for such a task. Suggestions?

like image 456
Bain Markev Avatar asked Oct 13 '10 15:10

Bain Markev


People also ask

How do I debug socket IO in Chrome?

Turn on the Chrome Developer Tools. Click Network, enable filter (3rd icon from the left on the top of Dev Tools) to filter the traffic shown by the Developer Tools, and click WebSockets. In the Echo demo, click Connect. On the Headers tab in Google Dev Tool you can inspect the WebSocket handshake.


1 Answers

Wireshark sounds like what you want actually. There is very little framing or structure to WebSockets after the handshake (so you want low-level) and even if there was, wireshark would soon (or already) have the ability to parse it and show you the structure.

Personally, I often capture with tcpdump and then parse the data later using wireshark. This is especially nice when you may not be able wireshark on the device where you want to capture the data (i.e. a headless server). For example:

sudo tcpdump -w /tmp/capture_data -s 8192 port 8000 

Alternately, if you have control over the WebSockets server (or proxy) you could always print out the send and receive data. Note that since websocket frames start with '\x00' will want to avoid printing that since in many languages '\x00' means the end of the string.

like image 87
kanaka Avatar answered Sep 17 '22 15:09

kanaka