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: https://github.com/theia-ide/theia/blob/6b8e776a29d4f4c67a4249b678055e2bb901a4b5/packages/core/src/node/messaging/messaging-contribution.ts#L109

[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’ ?