I try to proxy node.js, socket.io and xhr-polling traffic through nginx.
Then Socket.io doesn't fire "disconnect" event.
However, bellow condition works fine.
My version is bellow.
My nginx config file setting is below.
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_read_timeout 300;
proxy_connect_timeout 300;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
}
How can I fix this? Am I missing something? Thanks in Advance :)
In addition, I found new conditions that occurs my problem.
The result of my problem was depend on below.
The findings are following.
・ Chrome @ Mac OS X
・ Aquos Phone(Android Brower, Android 4.0.4)
port 80 ⇒ NG
port 3000 ⇒ OK
・ Gallaxy S(Android Brower, Android 4.2.2)
・ iPhone 5(Safari, iOS 7)
port 80 ⇒ NG
port 3000 ⇒ NG
Do you mean disconnect event when user closes the browser or tab? If so, try this code on the client side when you connecting to server:
io.connect('/', {
'sync disconnect on unload': true
});
(The first argument '/'
may be different in your configuration)
Here you can find details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.