Android APP stuck in Connecting .... seconds


#1

Hello,

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:

[Unit]
Description=Rocket.Chat server
After=network.target nss-lookup.target mongod.target

[Service]
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocket
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=https://nexxus.nuvem.top PORT=3000 DDP_DEFAULT_CONNECTION_URL=https://nexxus.nuvem.top
ExecStart=/usr/local/bin/node /opt/rocket/Rocket.Chat/main.js

[Install]
WantedBy=multi-user.target

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

upstream backend {
server 127.0.0.1:3000;
}

server {
listen 443;
server_name nexxus.nuvem.top;

ssl on;
ssl_certificate /etc/letsencrypt/live/nexxus.nuvem.top/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nexxus.nuvem.top/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

error_log /var/log/nginx/nexxus.nuvem.top-error.log;

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: 192.168.101.31, server: nexxus.nuvem.top, request: “GET /sockjs/info?cb=dx23dfasdf HTTP/1.1”, upstream: http://192.168.101.10:3000/sockjs/info?cb=dx23dfasdf", host: “nexxus.nuvem.top”, referrer: “https://nexxus.nuvem.top/home


#2

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.


#3


#4

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.


#5

new WebSocket(‘wss://nexxus.nuvem.top/websocket’);

WebSocket {url: “wss://nexxus.nuvem.top/websocket”, readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …}

binaryType:“blob”
bufferedAmount:0
extensions:“permessage-deflate”
onclose:null
onerror:null
onmessage:null
onopen:null
protocol:""
readyState:1
url:“wss://nexxus.nuvem.top/websocket”
proto:WebSocket


#6

Can someone help me?


#7

Can’t tell from this exactly whats happening try:

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

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


#8

Uncaught SyntaxError: Invalid or unexpected token


#9

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); }

#10


#11

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


#13

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


#14

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


#15

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