开发者

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 de开发者_开发知识库bugging purposes. How would I go about doing this? Wireshark seems too low level for such a task. Suggestions?


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.


If you're looking for the actual data sent and received, the recent Chrome Canary and Chromium have now WebSocket message frame inspection feature. You find details in this thread.


I think you should use Wireshark

Steps

  • Open wireshark
  • Go to capture and follow bellow path: capture > interfaces > start capture in your appropriate device.
  • Write rules in filter tcp.dstport == your_websoket_port
  • Hit apply


For simple thing, wireshark is too complex, i wanted to check only if the connection can be establish or not. Following Chrome plugin "Simple Web-socket (link : https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en)" work like charm. See image.

https://lh3.googleusercontent.com/bEHoKg3ijfjaE8-RWTONDBZolc3tP2mLbyWanolCfLmpTHUyYPMSD5I4hKBfi81D2hVpVH_BfQ=w640-h400-e365

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜