Skip to content

Bug: Cable error in logs and syncing not finishing (Self hosted) #2032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
javiermartingonzalez opened this issue Mar 28, 2025 · 6 comments

Comments

@javiermartingonzalez
Copy link

Hello, I was having an import errors after installing updates. It seems it was due new Redis component needed to be added to docker Compose.

I updated my Docker Compose using the given example and now it's importing my transactions like a charm.

But the "Syncing accounts data" is not finishing.

Checking the logs, I see the next error every time, is it related? Before installing the new version, the sync message was there only for a few seconds.

Also the dashboard is showing correctly the information of each account, but the aggregated sum is wrong (expected aggregated need to be Assets - Debts but something is not been calculated properly)

Image

[2025-03-28T23:40:33.099814 #1] INFO -- : {message: "Started GET \"/cable\"", event: {http_request_received: {body: nil, content_length: nil, headers_json: "{\"Host\":\"XXXXXXXX\",\"X_Real_Ip\":\"1XXXXXXXX\",\"X_Forwarded_For\":\"XXXXXXXXXXXX, XXXXXXXXX\",\"X_Forwarded_Proto\":\"https\",\"Connection\":\"close\",\"Cf_Ray\":\"927af922bf4ef769-MAD\",\"Cookie\":\"_maybe_session=8V%2BU28xCIhhbtysqMSzRrG372RZwNygl4vzVUPiTf5CBXLqRL2AHWpw4aYKOv5GA6n%2BcxpYy1Y5M9Pfru431TiicJGmDHKNSOPs69M4KfBJLRg55f7V7wxXU929BZv8NhcoyqBuCjL0hCLc5n5BCwEi75lkrdjna1OxGJUJEWtMx%2FRN3HVjYBqzuw3NMIWX9rcA6OH9W1vKFVADSXiUXq2ribLeRSpf4OYEFEzQtooSdPsUI30uPMjGkHZ04YudZhn4%2BEV%2B3evd1QR9o08ktTcqQFTeifg%3D%3D--wEw7o7VQor7e7Luk--JZlv0DQNiDY1UpXRgVo5HQ%3D%3D; session_token=eyJfcmFpbHMiOnsibWVzc2FnZSI6IklqQTVaamN4TnpKakxUSXpZall0TkRGbE5pMWhPV1l3TFRGa1ptUXdOMlkyTnpVMFlTST0iLCJleHAiOiIyMDQ1LTAzLTI4VDIzOjM1OjIzLjQ1N1oiLCJwdXIiOiJjb29raWUuc2Vzc2lvbl90b2tlbiJ9fQ%3D%3D--6f0dbc625d7d18559da45e6c7ac2a06735584c69\",\"Accept_Encoding\":\"gzip, br\",\"Cf_Ipcountry\":\"ES\",\"Priority\":\"u=3, i\",\"Accept_Language\":\"es-ES,es;q=0.9\",\"Cf_Visitor\":\"{\\\"scheme\\\":\\\"https\\\"}\",\"Accept\":\"*/*\",\"Sec_Fetch_Dest\":\"websocket\",\"Cf_Connecting_Ip\":\"XXXXXXXXX\",\"User_Agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15\",\"Origin\":\"XXXXXXXXX\",\"Cdn_Loop\":\"cloudflare; loops=1\",\"Pragma\":\"no-cache\",\"Sec_Websocket_Key\":\"bsvpeWVz6r7aDgzIpvRWoQ==\",\"Sec_Fetch_Site\":\"same-origin\",\"Sec_Websocket_Version\":\"13\",\"Sec_Websocket_Extensions\":\"permessage-deflate\",\"Sec_Websocket_Protocol\":\"actioncable-v1-json, actioncable-unsupported\",\"Sec_Fetch_Mode\":\"websocket\",\"Cache_Control\":\"no-cache\",\"Version\":\"HTTP/1.0\"}", host: "XXXXXXXXXX", method: "GET", path: "/cable", port: 443, query_string: "", request_id: "8408eb09-512e-4959-96ab-59aaa2e16f97", scheme: "https", service_name: nil}}} I, [2025-03-28T23:40:33.101923 #1] INFO -- : Started GET "/cable"[non-WebSocket] for XXXXXXXX at 2025-03-28 23:40:33 +0000 E, [2025-03-28T23:40:33.102506 #1] ERROR -- : Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: close, HTTP_UPGRADE: ) I, [2025-03-28T23:40:33.103265 #1] INFO -- : Finished "/cable"[non-WebSocket] for 162.158.122.120 at 2025-03-28 23:40:33 +0000 I, [2025-03-28T23:40:33.103837 #1] INFO -- : {message: "Completed 404 Not Found in 3.297398ms", event: {http_response_sent: {body: nil, content_length: nil, headers_json: "{\"content-type\":\"text/plain; charset=utf-8\"}", request_id: "8408eb09-512e-4959-96ab-59aaa2e16f97", service_name: nil, status: 404, duration_ms: 3.297398}}}

@javiermartingonzalez
Copy link
Author

Syncing and net worth fixed following issue: #2015

And querying the following command (I had 1 pending a 1 failed job):

DELETE FROM syncs
WHERE status IN ('failed', 'pending');

Action cable error still, I don't know if it's something that need to be solved or what are the side effects of that error

@zachgoll
Copy link
Collaborator

@javiermartingonzalez thanks for the report. I'll address each of the issues below:

Cable error

Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: close, HTTP_UPGRADE: )

This may be related to your reverse-proxy configuration. How are you hosting Maybe? Looks like you might be using Cloudflare in front of your domain?

Syncing not finishing

Yes, related to #2015 and deleting those pending syncs should fix that.

Net worth not correct

If syncs were stuck, we wouldn't be able to calculate the balances that make this up. So now that you've cleared out those pending syncs it should be correct?

@javiermartingonzalez
Copy link
Author

javiermartingonzalez commented Mar 31, 2025

Thank you @zachgoll for your answer!

Cable error

I'm hosting Maybe on my own Ubuntu server using Docker compose (the latest one with Redis and worker), but changing the exposed port for the webapp. Then with Nginx I'm assigning different subdomains under the same domain for the apps I have deployed on it. And finally, I'm accessing to it using CloudFlare as DNS resolver to hide my server IP information from public records.

Syncing not finishing and Net worth not correct

Yes, both things fixed after deleting pending syncs and doing a new successfully refresh.

@zachgoll
Copy link
Collaborator

zachgoll commented Apr 1, 2025

@javiermartingonzalez my guess is the cable error has something to do with Nginx not passing along the correct headers. Your setup seems relatively standard, but that's probably where I'd start looking.

@javiermartingonzalez
Copy link
Author

@zachgoll Thanks for your time!

I was able to solve it. My previous NGINX configuration was the following (I'm exposing Maybe app in 3004 port):

server {
    listen 443 ssl;
    server_name maybe.midomain.com;
    ssl_certificate /etc/nginx/ssl/cloudflare.crt;
    ssl_certificate_key /etc/nginx/ssl/cloudflare.key;

    location / {
        proxy_pass http://172.17.0.1:3004;
        proxy_set_header Host $host;
        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;
    }
}

Then I added the /cable location with the corresponding headers to support WebSocket.

As I learned today, the "Failed to upgrade to WebSocket" error indicates that WebSocket connection wasn't handled correctly (HTTP_CONNECTION: close and HTTP_UPGRADE empty). Without Upgrade and Connection headers, the backend server wasn't recognising it as WebSocket request.

So my new Nginx connection for that server name is:

server {
    listen 443 ssl;
    server_name maybe.mydomain.com;
    ssl_certificate /etc/nginx/ssl/cloudflare.crt;
    ssl_certificate_key /etc/nginx/ssl/cloudflare.key;

    location / {
        proxy_pass http://172.17.0.1:3004;
        proxy_set_header Host $host;
        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;
    }
    
    location /cable {
        proxy_pass http://172.17.0.1:3004/cable;
        proxy_set_header Host $host;
        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;
        
        #Support for WebSocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Now, it's working like a charm!

Thanks to @hibate (#1505 (comment)) for your Nginx example file with CableAction working and ChatGPT for explaining the theory to me. New thing learned today 😃

@zachgoll
Copy link
Collaborator

zachgoll commented Apr 4, 2025

@javiermartingonzalez awesome, thanks for sharing this solution! I'm sure it will help many others given how common the Nginx setup is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants