Answer the question
In order to leave comments, you need to log in
Why doesn't websocket want to work over cellular?
There is an application that uses a websocket connection (SockJS -> Nginx -> Tornado).
I observe strange behavior. The connection works fine if the laptop or phone is connected to Wi-Fi, but if you disconnect from Wi-Fi and use cellular, then the data from the server does not come.
At first I thought it was because of http, where either the headers could be cut off. Ok! Changed everything to https - did not help.
Nginx version 1.12.1;
Nginx config:
upstream ws_video {
ip_hash;
server 127.0.0.1:9101;
server 127.0.0.1:9102;
server 127.0.0.1:9103;
server 127.0.0.1:9104;
}
server {
listen 443;
server_name ____.ru;
ssl on;
ssl_certificate /home/admin/conf/web/ssl.____.ru.pem;
ssl_certificate_key /home/admin/conf/web/ssl.____.ru.key;
location / {
proxy_pass http://ws_video;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Answer the question
In order to leave comments, you need to log in
Look in the browser console to see what the server is responding to.
Try to connect "directly" (curl, telnet) on a cellular connection and see what happens.
From the theory of delirium: try another cellular connection.
All the problem was in the upstream! I removed it completely and added proxy_pass http://127.0.0.1:9101; and everything began to work. Also, the tornado launched not 4 workers, but one.
The Tornado also served as an annunciator. When the event happened, I did a POST to myself "requests.post(" https://____.ru/notify ", params=dict(message=string))" tornado processed it
from notification.connection import ClientConnection
class BroadcastHandler(tornado.web.RequestHandler):
def post(self):
message = self.get_argument('message', default="")
for client in ClientConnection.clients:
data = json.loads(message)
if data['dev'] in client.devices:
client.send(message)
self.write(str(ClientConnection.clients))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question