NGINX Websocket初始通信延迟

我创build了一个Django服务器,它使用Django通道进行websocket通信。 当我用NGINX运行服务器时,服务器和客户端之间的websocket通信有一个初始延迟。 在最初的延迟之后,所有丢失的数据在非常短的时间内到达,然后开始实时通信。

我已经testing了服务器的独立和没有NGINX代理只有一个达芙妮实例,并没有最初的通信延迟。

以下是我的NGINXconfiguration。 如果任何人有任何想法,为什么我会得到一个最初的10秒延迟websocket通信,将不胜感激。

worker_processes 1; events { worker_connections 1024; } http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 0; #gzip on; # the upstream component nginx needs to connect to upstream django { server 127.0.0.1:8001; } server { listen 80; client_max_body_size 20M; server_name localhost; location / { proxy_pass http://django; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } } 

附加信息:无论消息放入队列的速度如何,每次消息发送之前都会使用相同数量的消息,这意味着消息延迟不是基于时间的,而是基于缓冲区溢出的。 因为它不会发送任何数据,直到某种缓冲区被填充?