Theia: wss socket connection over apache not working (works good with http request)

Created on 15 Sep 2019  路  5Comments  路  Source: eclipse-theia/theia

Description

theia works well when used ipaddress like http://my.ip.add.ress:3000
Now, I set a proxy server https://sub.mydomain.tld to http://my.ip.add.ress:3000 and things get wrong.

Reproduction Steps

On the chrome console, i get this message
WebSocket connection to 'ws://ide.gsunitedtechnologies.com/services' failed: Error during WebSocket handshake: Unexpected response code: 404 v @ index.js:123

Event bubbles: false cancelBubble: false cancelable: false composed: false currentTarget: WebSocket {url: "ws://ide.gsunitedtechnologies.com/services", readyState: 3, bufferedAmount: 0, onopen: null, onerror: 茠, 鈥 defaultPrevented: false eventPhase: 0 isTrusted: true path: [] returnValue: true srcElement: WebSocket {url: "ws://ide.gsunitedtechnologies.com/services", readyState: 3, bufferedAmount: 0, onopen: null, onerror: 茠, 鈥 target: WebSocket {url: "ws://ide.gsunitedtechnologies.com/services", readyState: 3, bufferedAmount: 0, onopen: null, onerror: 茠, 鈥 timeStamp: 947.5099999981467 type: "error" __proto__: Event

OS and Theia version:
OS: Ubuntu 16.04 LTS
Theia Version : 0.11.0

Diagnostics:

needs more info question

Most helpful comment

@vanilla-thunder
The direct solutions is considering this as a websocket proxy. what you did seems to be working without issues. I tested with nginx as well.

For nginx,

location / {
    proxy_pass http://0.0.0.0:8080/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
}

All 5 comments

I don't think we do anything special with web sockets in Theia. You will need to have a look into your proxy configuration. Maybe @geropl can have an idea?

I just have installed theia in docker container behind apache proxy, here is my config:
<IfModule mod_ssl.c> <VirtualHost *:443> DocumentRoot /srv/www ServerName subdomain.server.com RewriteEngine On RewriteCond %{HTTP:Upgrade} =websocket [NC] RewriteRule /(.*) ws://localhost:3000/$1 [P,L] RewriteCond %{HTTP:Upgrade} !=websocket [NC] RewriteRule /(.*) http://localhost:3000/$1 [P,L] ... </VirtualHost> </IfModule>
haven't tested everything yet, but seems ok so far

He doesn't work for me..

I just have installed theia in docker container behind apache proxy, here is my config:

<IfModule mod_ssl.c>
<VirtualHost *:443>
  DocumentRoot /srv/www
  ServerName subdomain.server.com
  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)           ws://localhost:3000/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)           http://localhost:3000/$1 [P,L]
  ...
</VirtualHost>
</IfModule>

haven't tested everything yet, but seems ok so far

That's exactly the right solution. it works without issue. I did it with nginx directives, updated the code below.

@vanilla-thunder
The direct solutions is considering this as a websocket proxy. what you did seems to be working without issues. I tested with nginx as well.

For nginx,

location / {
    proxy_pass http://0.0.0.0:8080/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akosyakov picture akosyakov  路  3Comments

vince-fugnitto picture vince-fugnitto  路  3Comments

jeanlucburot picture jeanlucburot  路  3Comments

Beetix picture Beetix  路  3Comments

akosyakov picture akosyakov  路  3Comments