[SUPPORT] ios app can't connect to server
@vozerov commented on Tue Dec 11 2018
Description:
ios mobile app can't connect to server. The message is "Oops, can't connect to server"
Steps to reproduce:
Try to connect to rc.inmyroom.ru
Expected behavior:
Server Setup Information:
Rocket chat is deployed using docker. Server version is 0.72.2 Ubuntu 16.04 Nginx 1.15.7
Additional context
Nginx is setup as reverse proxy with letsencrypt ssl certificate installed. Nginx config was taken from issues thread at github (also tried config from official docs with no luck).
Relevant logs:
Websocket works fine as i see:
vozerov@mba:~ $ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: rc.inmyroom.ru" -H "Origin: rc.inmyroom.ru" -H "Sec-WebSocket-Key: fVXESE8fjBMx8HheW0YlZQ==" -H "Sec-WebSocket-Version: 13" https://rc.inmyroom.ru/websocket
�{"server_id":"0"}
^C
vozerov@mba:~ $ curl -D - -s https://rc.inmyroom.ru/api/v1/info
HTTP/1.1 200 OK
Server: nginx/1.15.7
Date: Tue, 11 Dec 2018 13:21:37 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-Instance-ID: axKHwC6ADyQzG8FH3
Access-Control-Allow-Origin: *
Cache-Control: no-store
Pragma: no-cache
Vary: Accept-Encoding
{"info":{"version":"0.72.2"},"success":true}
vozerov@mba:~ $
@tassoevan commented on Tue Dec 11 2018
@RocketChat/ios
@vozerov Problem is that your WebSocket connection upgrade is timing out the request... for me, this request is taking 47 seconds. Do you know what could be happening?
@rafaelks hm.. don't see any errors in neither rocketchat nor mongodb logs. Can you provide the query so i'll try to debug it somehow?
Thanks!
@vozerov I don't think the problem is related to MongoDB, but actually your server setup. I'll invite our @RocketChat/cloud team here, maybe they can help us.
@rafaelks thanks!
Just to clarify going to post current configs here:
- docker info: Server Version: 17.12.0-ce
- ubuntu: DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
- docker-compose: docker-compose version 1.19.0, build 9e633ef
- docker-compose.yml:
mongo:
image: mongo
volumes:
- /data/mongodb/data:/data/db
- /data/mongodb/dump:/dump
command: mongod --smallfiles
rocketchat:
image: rocketchat/rocket.chat:latest
environment:
- MONGO_URL=mongodb://db:27017/rocketchat
- ROOT_URL=https://rc.inmyroom.ru
- Accounts_UseDNSDomainCheck=True
links:
- mongo:db
ports:
- 3000:3000
hubot:
image: rocketchat/hubot-rocketchat:latest
environment:
- ROCKETCHAT_URL=136.243.67.215:3000
- ROCKETCHAT_ROOM=GENERAL
- ROCKETCHAT_USER=jarvis
- ROCKETCHAT_PASSWORD=password
- BOT_NAME=jarvis
- EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-greetings
links:
- rocketchat:rocketchat
ports:
- 3001:8080
- nginx config:
# Upstreams
upstream backend {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name rc.inmyroom.ru;
location /.well-known/acme-challenge {
root /opt/www/acme-root;
break;
}
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS Server
server {
listen 443 ssl;
server_name rc.inmyroom.ru;
client_max_body_size 200M;
error_log /var/log/nginx/rc.inmyroom.ru.access.log;
ssl_certificate /etc/letsencrypt/live/rc.inmyroom.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rc.inmyroom.ru/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
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;
}
}
- Server's load is ok - LA is about 0.5 with 8 cores.
Thanks!
@rafaelks any updates here? Can't find rocket chat cloud team really :(
do you have other LB's in the mix like aws ALB?
@geekgonecrazy nope, nginx only. It's a dedicated server with public ip, so just nginx and rocket chat server behind it.
I can definitely confirm for some reason something is happening preventing the websocket. If no other proxies in place. Maybe firewall? Or policy somewhere limiting length of tcp connections?
@LuluGO ideas to help determine cause of websocket issues?
@geekgonecrazy how do you test it?
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: rc.inmyroom.ru" -H "Origin: rc.inmyroom.ru" -H "Sec-WebSocket-Key: fVXESE8fjBMx8HheW0YlZQ==" -H "Sec-WebSocket-Version: 13" https://rc.inmyroom.ru/websocket
�{"server_id":"0"}
this command looks good so far or am I wrong?
Thanks!
Try that same command swapping those out for a known working server like open.rocket.chat. You’ll see the response is different
@geekgonecrazy @rafaelks thanks guys, it was really on my side. The problem was with ssi on; option. It was enabled at main config.
I believe we can close this issue now.
Out of curiosity what lead you to determine this? Would be good info to share with others
@vozerov @geekgonecrazy Amazing, thanks guys!
@geekgonecrazy oh... I don't know - simple troubleshooting :) I've started to check all the options nginx had when you mentioned open.rocket.chat. I saw the difference between answers with websocat tool and started to check all the options. One by one.
default_server, sendfile, tcp_nodelay, timeouts and so on. And when I saw ssi on; I realised that it's not commonly used option - so that's why I tried to disable it. And it worked :)
I couldn't find anything related to it at nginx issues. But I believe the problem is somewhere in parsing - nginx tries to parse rocket chat answers and include them as ssi. Maybe some directive or sth else looks like ssi include option and nginx tries to get it. And because it can't (resource not available, no dns, etc...) - it waits for timeout or sth similar to it.
So it's only my thoughts.
My point here is that:
- Set simple nginx.conf from package
- Set site conf from example above
- If it works - then the problem might be some nginx options.
- If it doesn't work - then the problem might be with sth else (firewall, Nodejs app, etc...)
thanks for sharing that :) hopefully will be useful to someone else.
i am having this problem too. I am on Google Cloud, Ubuntu 16.04 installed Snap, then used this process for the letsencrypt https://www.linode.com/docs/applications/messaging/installing-rocketchat-ubuntu-16-04/
i have done all of this before, but the first time I had a problem connecting from my IOS app. It works on the desktop client. The problem is i am not technical enough, I am good at following an exact set of instructions though :)
chat.fusechange.org is my server if anyone has any ideas