Websocket error

Dr Panos 5 years ago

Hello. I am using the web app from remote location and I am taking websocket errors. Also everything is with some seconds delay.
As I ubderstood it is browser issue. Only in firefox is working some times.
Any way to fix this?

Anton Tananaev 5 years ago

What makes you think it's a browser issue? It's usually a network problem.

Dr Panos 5 years ago

I thought it is browser issue because of the new security updates for Cross-origin resource sharing . Also in firefox it is working. What do you believe problem is?

Anton Tananaev 5 years ago

Just check the error in the browser developer tools instead of guessing.

Dr Panos 5 years ago

This is the error I am getting in console

WebSocketService.js:68 WebSocket connection to 'wss://domain/api/socket' failed: Error during WebSocket handshake: Unexpected response code: 503
(anonymous) @ WebSocketService.js:68
c @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
i @ asyncToGenerator.js:3
s @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
(anonymous) @ WebSocketService.js:14
(anonymous) @ WebSocketService.js:185
c @ runtime.js:63
(anonymous) @ runtime.js:293
(anonymous) @ runtime.js:118
i @ asyncToGenerator.js:3
s @ asyncToGenerator.js:25
Anton Tananaev 5 years ago

Looks like you have HTTPS configured that you haven't mentioned before. Are you sure you configured proxy correctly? Have you tried without it?

Dr Panos 5 years ago

Yes proxy is configured. remote location is also HTTPS . It is making the same even with http.

Anton Tananaev 5 years ago

Let's see the proxy config.

Dr Panos 5 years ago

This is the config

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>

                ServerName mydomain.com
                ServerAdmin webmaster@localhost

                DocumentRoot /var/www/html

                ProxyPass /api/socket ws://localhost:8080/api/socket
                ProxyPassReverse /api/socket ws://localhost:8080/api/socket

                ProxyPass / http://localhost:8080/
                ProxyPassReverse / http://localhost:8080/

                SSLEngine on

                SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
        </VirtualHost>

<VirtualHost *:80>
  ServerName mydomain.com
  Redirect / https://mydomain.com
</VirtualHost>



</IfModule>
Anton Tananaev 5 years ago

Which Apache modules do you have enabled? Specifically proxy_wstunnel has to be enabled.

Dr Panos 5 years ago

ssl,
proxy_http,
and proxy_wstunnel
The https is working ok locally. If I access the domain I have no errors. The problem is when the web app is on remote server.

Anton Tananaev 5 years ago

OK, I don't have any other ideas.