nginx - webpage only can get the latest state of background process by refresh the webpage -


i have painful problem. use flask-socketio update states of background process onto webpage. example, app put in machine ip 170.8.8.8 monitoring port 5000, , put nginx in machine b ip 170.8.8.9 monitoring port 5000. want visit ip:5000 in b skip ip:5000 in a. below nginx config in machine b:

upstream cuitccol.com{ #the name of server cluster         server 170.8.8.8:5000 max_fails=5 fail_timeout=50s; #for first web server         }      server {         listen       5000;         server_name  localhost;          #charset koi8-r;          #access_log  logs/host.access.log  main;          location / {             proxy_pass http://cuitccol.com;             proxy_http_version 1.1;             proxy_set_header upgrade $http_upgrade;             proxy_set_header connection "upgrade";             proxy_set_header host $host;         }  

if directly visit ip in a, webpage of browser can updates state of background process. if visit b nginx put, the webpage can not updates state, , must refresh webpage next state. , console of browser has mistake below:

websocket connection 'ws://170.8.8.9:5000/socket.io/?eio=3&transport=websocket&sid=4a2ec29f7f834a0bb289b21f03c3e47c' failed: error during websocket handshake: unexpected response code: 200 

i not know goes wrong. nginx or flask-socketio. can give advises? thank much~

change config below

   location / {         proxy_pass http://cuitccol.com;         proxy_http_version 1.1;     }      location /socket.io {         proxy_pass http://cuitccol.com/socket.io;         proxy_http_version 1.1;         proxy_buffering off;         proxy_set_header upgrade $http_upgrade;         proxy_set_header connection "upgrade";     }  

and see if helps. upgrade headers should used socket , not rest of endpoints


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -