0

This error appears only when i connect from android application using mobile internet, but via wifi all works.

nginx error.log:

connect() failed (111: Connection refused) while connecting to upstream, client: 79.143.100.252, server: 0.0.0.0, request: "GET /socket.io/?EIO=3&transport=websocket HTTP, upstream: "http://127.0.0.1:8001/socket.io/?EIO=3&transport=websocket", host: "XX:XX:XX:XX"

nginx access.log:

"GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 101 104 "-" "okhttp/3.5.0"

In websocket app i see always accepted connecting (infinity reconnection) but no events were called.

My nginx conf:

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

server {
    listen 80;
    server_name 0.0.0.0;

    location / {
        proxy_pass http://127.0.0.1:8000;
    }

    location /socket.io {
        proxy_send_timeout 150;
        include proxy_params;
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass http://127.0.0.1:8001/socket.io;
    }
}

UPDATE:

It was Android issue - we needed to delete all additional settings for okhttp

  • Show backend logs. Check/add `proxy_set_header Host $http_host`. Sorry, this is not a solution, but I could not resist. `server_name 0.0.0.0` is very misleading, it is not related to listen address, it's a name to match against `Host` header. `proxy_pass http://127.0.0.1:8001` is enough and will implicitly pass `/socket.io` path to backend. – temoto May 25 '17 at 00:12
  • How reliable is your mobile network connection? Are you seeing these errors every single time, or do they happen after the connection was up for a little bit of time? It could be just that the connection drops. I recently discovered a bug that caused the reconnections on flaky networks to not always work, so make sure you have the latest versions of all the Socket.IO packages installed. – Miguel Grinberg May 25 '17 at 14:54
  • sorry for long time answer - yes, all time – Максим Стукало Jun 06 '17 at 14:07

0 Answers0