Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you inspect websocket traffic with Chrome Developer Tools? [duplicate]

I'm trying to inspect websocket traffic using Chrome Developer Tools. From my research it seems you should be able to see it using the network tab - and it even has a filter for 'ws'.

However I've been inspecting sites that I know are using websockets and can't find a way to inspect the messages being sent back and forth. Using Chrome v56, also tried Safari with no luck...

Does anyone know how this can be achieved?

like image 401
Joel Duckworth Avatar asked Mar 28 '17 22:03

Joel Duckworth


People also ask

How do you intercept traffic on WebSockets?

To intercept the messages, you will have to spy on the onmessage = fn and addEventListener("message", fn) calls. To be able to modify the onmessage we have to override the global WebSocket in the first place.

How do I stop traffic on Google Chrome WebSockets?

When you want to turn off WebSockets, click on the TamperMonkey icon and the toggle switch to enable blocking. Refresh the page. Disable the script when you no longer want to block WebSockets.

Does Google Chrome support WebSockets?

You can use Google Chrome and pywebsocket to start implementing Web Socket-enabled web applications now.


1 Answers

You need to reload the page with the network tab open and filter by type 'ws'. This will show you a connection being made with a websocket. You can then click on the connection to show the traffic being sent back and forth with on the server

enter image description here

https://developers.google.com/web/tools/chrome-devtools/network-performance/reference#frames

like image 164
Joel Duckworth Avatar answered Nov 14 '22 16:11

Joel Duckworth