walkor / phpsocket.io

A server side alternative implementation of socket.io in PHP based on workerman.
2.3k stars 508 forks source link

Infinite reconnection #256

Closed dividerbeam closed 3 years ago

dividerbeam commented 3 years ago

Client side: var socket = io('https://'+document.domain+'/socket.io/');

Nginx:

location /socket.io/ {
        proxy_pass http://myServerIP:2020/socket.io/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Real-IP $remote_addr;
    }

and result: socketio

server answer: 96:0{"sid":"VlC_PZXQOS4w8sowB6Yt","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000}

i think problem with "sid", its not saved after first connect, but i dk how fix that

help plz

walkor commented 3 years ago

Try config

location /socket.io {
        proxy_pass http://myServerIP:2020;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Real-IP $remote_addr;
    }

Client side: var socket = io('https://'+document.domain);

dividerbeam commented 3 years ago

thank you very much!