[question] 502/499 errors when calling Centrifugo API - centrifugo

Describe the bug. A clear and concise description of what the bug is.

My backend sometimes get 499 HTTP error / 502 HTTP error, when sending HTTP requests to the centrifugo /api. Centrifugo is proxified by Nginx.

Centrifugo config: { "engine": "redis", "redishost": "127.0.0.1", "redisport": "6379", "v3useoffset": true, "tokenhmacsecretkey": "*", "apikey": "", "client_anonymous": true, "presence": true, "namespaces": [ { "name": "livefeed", "anonymous": true }, ], "proxy_connect_endpoint": "https:///api/centrifugo/connect", "proxyconnecttimeout": 1, "proxyrefreshendpoint": "https://*/api/centrifugo/refresh", "proxyrefreshtimeout": 1 }

Nginx config: upstream centrifugo { # Enumerate all the Tornado servers here #sticky; ip_hash; server 127.0.0.1:8000; server 127.0.0.1:8001; server 127.0.0.1:8002; #server 127.0.0.1:8001; keepalive 5000; }

location /centrifugo/ {
    add_header Access-Control-Allow-Origin *;

    rewrite ^/centrifugo/(.*)        /$1 break;
    proxy_pass_header Server;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Scheme $scheme;
    proxy_pass http://centrifugo;
}

location /centrifugo/connection {
    add_header Access-Control-Allow-Origin *;

    rewrite ^/centrifugo(.*)        $1 break;

    proxy_next_upstream error;
    gzip on;
    gzip_min_length 1000;
    gzip_proxied any;
    proxy_buffering off;
    keepalive_timeout 65;
    proxy_pass http://centrifugo;
    proxy_read_timeout 60s;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Scheme $scheme;
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}
Asked Sep 28 '21 06:09
avatar car1ot
car1ot

2 Answer:

Hello, these codes are non-application level errors - 499 is internal Nginx error for the case when a client closed the connection while Nginx is processing the request. 502 often means that service is simply unreachable on network level (no connectivity).

You can try to deal with them using retries. If these errors happen very often then try to investigate possible infrastructure problems.

I don't see at the moment how both can indicate any bug in Centrifugo.

In which environment are you running Nginx/Centrifugo/App backend - is it Kubernetes or bare metal server or sth else?

1
Answered Jan 24 '21 at 12:01
avatar  of FZambia
FZambia

Closing, since no response from op for more than a week. @car1ot feel free to ask questions in our community chats (Telegram, Discord - links in readme), if you provide more information on use case and pattern - there could be some action points to fix in Centrifugo, but for now I don't see nothing actionable here.

1
Answered Feb 01 '21 at 09:49
avatar  of FZambia
FZambia