admin管理员组文章数量:1277896
I am running a WebSocket server behind Nginx, and I have two different implementations: one in Node.js and one in Python. The Node.js WebSocket server receives all messages correctly, but the Python server misses one of the messages.
WebSocket Message Flow:
- Client opens WebSocket:
/my-app/14515/
- Client sends message:
{ "type": "my-app:react_api:editor", "url_kwargs": {...} }
- Client sends message:
{ "type": "my-app:react_api:problem", "url_kwargs": {...} }
- Client opens another WebSocket:
/editor/14515/
When using Node.js, both messages (my-app:react_api:editor
and my-app:react_api:problem
) are received. But when using Python, only the first message (my-app:react_api:editor
) is logged, and the second one is missing.
Nginx Configuration:
location /ws/ {
proxy_pass http://127.0.0.1:8387/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
include proxy_params;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Node.js WebSocket Server (Works Fine)
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8387 });
wss.on('connection', (ws, req) => {
const clientIP = req.socket.remoteAddress;
const clientURL = req.url || '/';
console.log(`✅ New connection from ${clientIP}, URL: ${clientURL}`);
ws.send("
本文标签:
WebSocket Server in Python Not Receiving All Messages While Nodejs DoesStack Overflow
版权声明:本文标题:WebSocket Server in Python Not Receiving All Messages While Node.js Does - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1741219427a2360679.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论