Using Theia without websockets support

Hello, dear Theia Community.

I would like to use theia in an environment without WebSocket connection support due to proxy security settings. Is it possible somehow to switch the communication into gRPC over HTTP/2 or SSE (for example)?

Would be great to have such an option in place, but even a bit of simple advice on how this could be implemented would be quite helpful.

Your biggest issue will be supporting server events to the clients, but it might be doable.

Please look into rebinding the WebSocketConnectionProvider and MessagingContribution classes. Starting from those you should be able to replace the ws implementation by your custom one.

I think it should work with gRPC duplexes; it’s bidirectional.

It seems to be a beefy work :muscle: You have to create the “proto” version of every single service interface and type we use, and you have to regenerate it every single time the API changes.

Let us know if you have found the solution and want to come back to Theia with a PR :wink:

The problem here is the browser environment. You don’t have a lot of options for server-to-client events…

The only mechanisms I know about:

  • Long polling
  • HTTP Event Sources
  • WebSockets

Isn’t the scope of his post to simply replace the transport layer to not use WebSockets?

Isn’t the scope of his post to simply replace the transport layer to not use WebSockets?

Yes, exactly. I don’t want to change existing services or APIs, only replace the transport layer.

Then I repeat:

1 Like

Hi @paul-marechal!
Quick question in this regard - I’ve decided to implement this via SSE.
How can I replace the WebSocketConnectionProvider with my own implementation?
I see two options:

  • use this instruction, add my extension and somehow disable the WebsocketConnectionProvider
  • fork theia and directly rewrite all bits related to WebsocketConnectionProvider

what would be a better approach?

I’d recommend using a Theia extension which will allow you to rebind the WebSocketConnectionProvider identifier from the Inversify module containers.

1 Like