我使用Nginx 1.10.1来为我的APP平衡Websocket连接。
例如,应用程序A (多进程)通过Nginxbuild立到B1 , B2 Websocket连接,以便连接可以平衡。
使用它时,有时即使我的应用程序通过Websocket发送消息,终点( B1或B2 )不会收到任何消息,并在一段时间后Nginx打印错误日志消息recv() failed (110: Connection timed out) while proxying upgraded connection 。
以下是我对Nginxconfiguration。
为什么会发生,如何解决? 像networking连接超时会导致这种情况?
worker_processes 2; error_log /app_log/sangmin/nginx/error.log info; pid /app_log/sangmin/nginx/nginx.pid; events { worker_connections 1024; use epoll; } http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } client_body_buffer_size 5m; access_log /app_log/sangmin/nginx/access.log; upstream s2s_host{ hash $remote_port; server 10.2.150.211:8080 max_fails=0 fail_timeout=10s;server 10.2.150.212:8080 max_fails=0 fail_timeout=10s; } server { listen 10.2.14.195:10002; location = /s2s { proxy_read_timeout 365h; proxy_send_timeout 365h; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_pass http://s2s_host; } } }