I am using Nginx 1.10.1
for my APP to balance connections on Websocket
.
For example, the App A
(multi-process) establish Websocket
connections to B1
, B2
through Nginx
so that the connections could be balanced.
While using it, sometimes even though my App send messages through the Websocket
, the end-point(B1
or B2
) doesn't receive any message and after a while Nginx
prints the error log message recv() failed (110: Connection timed out) while proxying upgraded connection
.
The below is my config for Nginx
.
Why does it happen and how to fix it ? Something like connection timeout over network would lead this situation ?
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;
}
}
}