How to track websocket activity?

How would you go about monitoring a user’s traffic (in a dockerized Theia container)? I don’t need anything complex, just simply want to understand if it’s possible to see something like nginx access logs, but for the websocket traffic within Theia. I don’t necessarily need to know which action was made—opening a file, running a command at the terminal, etc.—I only need to know that a request was sent and received. (Though, if possible, I’d be interested in more detailed data.)

So, how would you go about this?

[original thread by Brian Dant]

We don’t log them anythere. For debugging purposes one can use dev tools. Some services, like language servers, allow to enable tracing via preferences, then requests/reponses can be inspected in the output view.

You can intercept any ws by overriding this method:

[Brian Dant]

Excellent. Thanks so much, @anton-kosyakov!

hey @akosyakov, how can we go about overriding the ‘handleConnection’ method ?
Do I need to extend the MessagingContribution class that has the member and then rebind it or do I need to rebind the classes ‘messagingBackendModule’ and also ‘BackendGenerator’ ?