Lost WebSocket connection with Safari while running a Bokeh server - nginx

I'm setting up a Bokeh plot on a remote server and I'm having this problem with Safari. When I connect to the website, the plot shows up, but instantly, the WebSocket connection closes itself, as if the browser was closed.
When I try with Chrome, everything is fine.
Here is my reverse proxy config (nginx):
server {
listen 80 default_server;
server_name bokeh_host;
root /var/www/html;
index index.nginx-debian.html;
access_log /srv/log/bokeh.access.log;
error_log /srv/log/bokeh.error.log;
location / {
}
location /bokeh_plot {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_buffering off;
}
location /static {
alias /srv/static;
}
}
Here is my bokeh command:
bokeh serve bokeh_plot.py --port 5000 --host *.domain.com
Here is what I see in the Terminal:
As you can see, the WebSocket connection closes itself right after being created. In the end, I can see the plot, but it's not interactive anymore since the WS connection is lost.
Is this something with Safari? Does someone have seen this bug too? Or maybe it is because of my config?

This actually is a (quite recent) Safari problem. It seems to happen only when plots are too big.
Anyway, I tried it with Safari Technology Preview R28, as suggested on GitHub, and it works well. I guess we'll have to wait for the next Safari update.

Related

No messages are being sent in Blazor Server behind Nginx

I have a blazor-server application, which works correctly in all cases other than running behind reverse proxy (I've only tested with NGINX).
Browser is able to connect to /_blazor?id=xyz endpoint and successfully send/receive heartbeat messages. But events with button click etc. does not work at all. There are no error or warnings in console and application's logs.
Nginx config is written according to this .NET docs
Here is my setup:
map $http_connection $connection_upgrade {
"~*Upgrade" $http_connection;
default keep-alive;
}
server {
listen 80;
server_name service.example.com;
location / {
# App server url
proxy_pass http://localhost:9000;
# Configuration for WebSockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache off;
# WebSockets were implemented after http/1.0
proxy_http_version 1.1;
# Configuration for ServerSentEvents
# proxy_buffering off; # Removed according to docs
# Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds
proxy_read_timeout 100s;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
I think the problem is because of nginx, as app works fine on my local machine.
If you need any more data, please comment below, I will provide.
Thanks in advance.
Apparently, cloudflare was also configured to proxy my request, and this somehow affected it.
Disabling cloudflare proxy and configuring https with let's encrypt solved the issue

pouchdb doesn't create remote db on nginx server on Sync resulting lots of 404 on GETs and POSTs

I have added a basic authentication on localCouchDb (http://localhost:5984/testdb). And sync works fine with credentials.
On remoteCouchdb (http:remote_ip/testdb) which I've configured on nginx with below snippet:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name myDomain.com www.myDomain.com;
location / {
proxy_pass http://localhost:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ ^/(.*)/_changes {
proxy_pass http://localhost:5984;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
I have enabled WWW-Authenticate = Basic realm="administrator" for both local and remote couchDb in local.ini file.
On remoteCouchDb too I have the same credentials which seems to be working. But at the time of sync operation, I'm getting growing number of errors like below:
GET http://***remote_ip***/testdb/_local/x8B36az7Yezgye.7zCNXwA%3D%3D? 404
POST http://***remote_ip***/testdb/_revs_diff 404 (Object Not Found)
It looks like, sync operation is not able to create testdb on remote. Verified by hitting 'http://remote_ip/testdb'.
I can visit Futon page both on localCouchDb (http://localhost:5984/_utils/), and remoteCouchDb (http://remote_ip/_utils/).
Only difference is the version of couchDb; on local, couchDb version is "1.6.0" and on remote it is "1.6.1". Is this is a problem or have I missed any configuration on remoteCouchDb?
Though I'm embarrassed with the question I asked, I found the solution. Unlike couchdb 1.6.0, you have to create the database in 1.6.1, in fact same for 2.1.2 (So I guess from version 1.6.1 we need to create the database on our own in the beginning).

Nginx not displaing Phoenix web app

I'm trying to deploy a basic Phoenix app to a DigitalOcean server running ubuntu 14.04. I'm using exrm to generate the release. The release works when I test it on my local machine and on the server. I'm following the Phoenix guides on deployment. The thing that doesn't seem to work is the last part with the nginx server setup. For some reason I cant get it to load anyting but the default page. When I run the
nginx -t # command. It says everything is fine.
I've tried editing the /etc/nginx/sites-available files. Doesn't seem to do anything. I've tried restarting the nginx server with
sudo service nginx reload
sudo service nginx restart
But that doesn't seem to work either.
And this is the content of my /etc/nginx/sites-available/my_app.conf
upstream my_app {
server 127.0.0.1:4000;
}
server{
listen 80;
server_name www.example.com;
location / {
try_files $uri #proxy;
}
location #proxy {
include proxy_params;
proxy_redirect off;
proxy_pass http://my_app;
# The following two headers need to be set in order
# to keep the websocket connection open. Otherwise you'll see
# HTTP 400's being returned from websocket connections.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
Update: Tried connecting directly via server_ip:port, and it worked. The url still doesnt display anything.
Solved: For some reason deleting this solves the problem.:
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
Solved: For some reason deleting this solves the problem.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

WebSocket opening handshake timed out

I'm working on a Google Cloud Compute Engine instance. Ubuntu 12.04.
I have a Tornado app installed on the server working on port 8888 and I have nginx configuration as shown below:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream chat_servers {
server 127.0.0.1:8888;
}
server {
listen 80;
server_name chat.myapp.com;
access_log /home/ubuntu/logs/nginx_access.log;
error_log /home/ubuntu/logs/nginx_error.log;
location /talk/ {
proxy_set_header X-Real-IP $remote_addr; # http://wiki.nginx.org/HttpProxyModule
proxy_set_header Host $host; # pass the host header - http://wiki.nginx.org/HttpProxyModule#proxy_pass
proxy_http_version 1.1; # recommended with keepalive connections - http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version
# WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://chat_servers;
}
}
When I try to connect to ws://chat.myapp.com/talk/etc/ via Javascript, Tornado app's open() method on WebSocketHandler gets called and I print the log on the server successfully, but on the client side, the code never enters the onopen() and after some time I get 1006 error code,WebSocket opening handshake timed out`.
This app was working fine on Amazon (AWS) EC2 server with the same configuration but after I moved to Google Cloud, somehow the handshake cannot be done.
Is there any configuration specific to Google Cloud? Or any nginx update on the file?
I am confused and I spent two days on this but couldn't solve the problem.
Default nginx's version on Ubuntu was nginx/1.1.19. I updated it to nginx/1.8.0. The problem is solved.

Tornado WebSocket Server without proxy

I have a tornado websocket server that works fine on my local machine. but when I deploy it to a web server and run it with supervisord I cant connect with javascript websockets.
I have tried to open the port in firewall but doesnt work.
I also tried to use a proxy with nginx (and the tcp module)
tcp {
upstream websockets {
server abc.de.efg.hij:23581;
check interval=3000 rise=2 fall=5 timeout=1000;
}
server {
listen abc.de.efg.hij:45645;
server_name _;
tcp_nodelay on;
proxy_pass websockets;
}
}
but also doesnt work.
whats wrong here?
You need to add an extra 'location' section for the websocket to make sure the upgrade headers are passed correctly:
location /YOUR_SOCKET_ENDPOINT/ {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Docs are here: http://nginx.org/en/docs/http/websocket.html

Resources