Android APP stuck in Connecting .... seconds


OS: CentOS 7
Nginx 1.12.2
Node: v8.11.3
RocketChat: 0.69.1
RocketChat Android App: 2.5.1 Build 2036
SSL Cert from Let´s Encrypt

After all set, i cannot view the Chats in Android APP. My system is fully operational via web. I have already done a long search on the internet and in the forum. I saw that there are some mentions regarding the configuration of the websocks, but I’m using nginx.

Here are my service config file in /etc/systemd/system/rocketchat.service:

Description=Rocket.Chat server

Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL= PORT=3000 DDP_DEFAULT_CONNECTION_URL=
ExecStart=/usr/local/bin/node /opt/rocket/Rocket.Chat/main.js


Here are my /etc/nginx/conf.d/default.conf:

upstream backend {

server {
listen 443;

ssl on;
ssl_certificate /etc/letsencrypt/live/;
ssl_certificate_key /etc/letsencrypt/live/;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

error_log /var/log/nginx/;

location / {
    proxy_pass http://backend/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;

    proxy_redirect off;


From time to time the following error appears in the nginx logs:

[error] 1091#0: *1 connect() failed (111: Connection refused) whlie connecting to upstrem, client:, server:, request: “GET /sockjs/info?cb=dx23dfasdf HTTP/1.1”, upstream:", host: “”, referrer: “

The error your seeing in the logs looks like errors coming from web client.

Can you check your connection log in your browser console? From there look and see if a websocket connection is being made.

To bring that up right click and inspect page, then go to the network tab. Once that’s open reload the page.

Can you switch to the console tab and paste:

new WebSocket('wss://{your server}/websocket');

of course replacing {your server} with your servers hostname.

Let me know what it spits out.

new WebSocket(‘wss://’);

WebSocket {url: “wss://”, readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …}


Can someone help me?

Can’t tell from this exactly whats happening try:

sock = new WebSocket(‘wss://’); sock.onerror = function(err) { console.log(err); };

That should log an error then if there is one. Give it a few minutes.

Uncaught SyntaxError: Invalid or unexpected token

Ah sorry… typed it from memory. Forgot sock is likely reserved.

var websock = new WebSocket('wss://{your server}/websocket'); websock.onerror = function(err) { console.log(err); }

What about the output of:
export HOST={your host here} && curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: $HOST" -H "Origin: $HOST" -H "Sec-WebSocket-Key: fVXESE8fjBMx8HheW0YlZQ==" -H "Sec-WebSocket-Version: 13" https://$HOST/websocket

Okay – I tested his config with curl – and it worked – HOWEVER it seems to be failing – he’s using verbatim the working config from my server – and it should work…but it’s not…not sure what’s up

OK this is good! Lets see if the mobile team has any ideas, it could be on that end now that we know everything with your websocket is good looks like websocket connections are actually returning 400 bad request.

After some discussion on #support all is resolved. Seems double reverse proxy due to a network device

In the end the problem was with my Firewall / UTM.
I needed to enable WebSocket passthrough and it was disabled.