Self-hosted instance constantly saying 'Reconnecting' on web UI and eventually goes to 'Failed'

I am running a self-hosted instance using docker-compose within Portainer.
The instance seems to run without issue. I can create tables and add/import data. But every single page I go to I received a pop-up in the top right corner of the screen. On initial loading, I receive ‘Reconnecting with server.’
image
If I stay on the webpage for around 2 - 4 minutes the popup changes to the following ‘Connection to the server has failed. Please refresh the page.’

I have not found any error messages within the docker logs that seem to be connected with this issue. I even have log level set to debug and backend debugging turned on.

Below is my docker-compose setting file.

version: "3.4"

volumes:
  baserow_data:
  
services:
  baserow:
    container_name: baserow
    image: baserow/baserow:1.11.0
    restart: unless-stopped
    environment:
      BASEROW_PUBLIC_URL: 'myCustomDomain'
      BASEROW_BACKEND_LOG_LEVEL: 'DEBUG'
      BASEROW_BACKEND_DEBUG: 'on'
    ports:
      - "6000:80"
      - "6100:443"
    volumes:
      - baserow_data:/baserow/data
2 Likes

This error indicates your browser is failing to open a websocket connection to the baserow server. In your browsers network log you should see these connections failing, do they have a specific error? With various other reverse proxies you often have to enable some specific config to allow through websockets, but i wasn’t aware of any portainer specific settings that it uses for websockets. Alternatively your browser itself might be blocking these websocket connections.

I’m having this same issue also. From the browser:

97ff761.js:1 WebSocket connection to 'wss://baserow.libertymarketing.me/ws/core/?jwt_token=...' failed: 

I am using nginx to proxy with ssl on port 443 to the baserow container on port 80. In the baserow logs i see this:

 [BACKEND][2022-12-07 15:13:34] 172.23.0.1:0 - "GET /ws/core/?jwt_token=... HTTP/1.1" 404  
 [BACKEND][2022-12-07 15:13:34] WARNING 2022-12-07 15:13:34,944 django.request.log_response:224- Not Found: /ws/core/   
 [BACKEND][2022-12-07 15:13:34] WARNING 2022-12-07 15:13:34,944 django.request.log_response:224- Not Found: /ws/core/   

i’m using baserow/baserow:1.13.1

I found that nginx has to be configured to handle websockets:

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

in the location block fixes the error in the browser

1 Like

@dab I manage to get another platform (n8n) working with the same header in a pleask server. Acutally two, uptime-kuma also worked. But for some reason Baserow does not. Can you help?

Can you see any of the server logs? What kind of web server? nginx? apache?

This matter has also happened to me and cost me 5 hours to find out the reason. I set up my Baserow using Docker with Caddy + Nginx (with reverse proxy).

The 400 error code came from the Docker (using docker logs container_id) instead of from Nginx. Also I noticed that when I cleared my browser cookies, it has no issues; when I visited a couple of different pages and accumulated a lot of cookies, the issue reproduces. Therefore, the issue is: the cookie header is too large > http connection upgrade failed at handshake.

To solve this issue, simply remove all cookies for WS connections in Nginx using “proxy_hide_header Cookie”, “add_header Cookie”, and “proxy_set_header Cookie”. Below are my settings in Nginx:

    location ~ ^/api/ {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://127.0.0.1:1080;
    }
    location ~ ^/ws/ {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_hide_header Cookie;
        add_header Cookie "";
        proxy_set_header Cookie "";
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://127.0.0.1:1080;
    }
1 Like

thank you so much! it’s amazing!