schech1 / uptime-buddy

Uptime monitoring on Apple Watch
https://apps.apple.com/de/app/uptime-mate/id6503297780
MIT License
98 stars 3 forks source link

App successfully builds a TCP connection but fails anyway #18

Closed FireIP closed 1 month ago

FireIP commented 1 month ago

I set up the backend and Kuma on my server. The logs claim that the backend can connect to Kuma. Now, to the issue: when I try to connect to the backend, it takes a while and then fails with the error: Network error occurred: The request timed out. So, I started tcpdump to see if the packets get forwarded. My capture tells me that the app manages to build and gracefully end a TCP connection, even exchanging some data. Still, the app reports a connection error. There is no output in the docker logs for uptime-buddy-api besides the startup.

I might be going crazy. It is late, and I am probably missing something obvious. Please tell me if there is any way to get more detailed logs, errors, or other info on why the connection fails. Thanks a lot for putting the effort into creating this project and pushing it to Git. If you know which part is failing or why, let me know. I really appreciate any help you can provide.

The tcpdump:

> sudo tcpdump -i any -n port 5005
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
02:26:53.599218 eno1  In  IP 192.168.178.106.65340 > 192.168.178.89.5005: Flags [S], seq 375692638, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 1948263939 ecr 0,sackOK,eol], length 0
02:26:53.599329 docker0 Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [S], seq 375692638, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 1948263939 ecr 0,sackOK,eol], length 0
02:26:53.599344 vetha9d3a9e Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [S], seq 375692638, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 1948263939 ecr 0,sackOK,eol], length 0
02:26:53.599483 vetha9d3a9e P   IP 172.17.0.3.5005 > 192.168.178.106.65340: Flags [S.], seq 3717500441, ack 375692639, win 65160, options [mss 1460,sackOK,TS val 3259123595 ecr 1948263939,nop,wscale 7], length 0
02:26:53.599498 docker0 In  IP 172.17.0.3.5005 > 192.168.178.106.65340: Flags [S.], seq 3717500441, ack 375692639, win 65160, options [mss 1460,sackOK,TS val 3259123595 ecr 1948263939,nop,wscale 7], length 0
02:26:53.599522 eno1  Out IP 192.168.178.89.5005 > 192.168.178.106.65340: Flags [S.], seq 3717500441, ack 375692639, win 65160, options [mss 1460,sackOK,TS val 3259123595 ecr 1948263939,nop,wscale 7], length 0
02:26:53.603578 eno1  In  IP 192.168.178.106.65340 > 192.168.178.89.5005: Flags [.], ack 1, win 2058, options [nop,nop,TS val 1948263947 ecr 3259123595], length 0
02:26:53.603578 eno1  In  IP 192.168.178.106.65340 > 192.168.178.89.5005: Flags [P.], seq 1:518, ack 1, win 2058, options [nop,nop,TS val 1948263947 ecr 3259123595], length 517
02:26:53.603668 docker0 Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [.], ack 1, win 2058, options [nop,nop,TS val 1948263947 ecr 3259123595], length 0
02:26:53.603684 vetha9d3a9e Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [.], ack 1, win 2058, options [nop,nop,TS val 1948263947 ecr 3259123595], length 0
02:26:53.603693 docker0 Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [P.], seq 1:518, ack 1, win 2058, options [nop,nop,TS val 1948263947 ecr 3259123595], length 517
02:26:53.603696 vetha9d3a9e Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [P.], seq 1:518, ack 1, win 2058, options [nop,nop,TS val 1948263947 ecr 3259123595], length 517
02:26:53.603801 vetha9d3a9e P   IP 172.17.0.3.5005 > 192.168.178.106.65340: Flags [.], ack 518, win 506, options [nop,nop,TS val 3259123600 ecr 1948263947], length 0
02:26:53.603817 docker0 In  IP 172.17.0.3.5005 > 192.168.178.106.65340: Flags [.], ack 518, win 506, options [nop,nop,TS val 3259123600 ecr 1948263947], length 0
02:26:53.603837 eno1  Out IP 192.168.178.89.5005 > 192.168.178.106.65340: Flags [.], ack 518, win 506, options [nop,nop,TS val 3259123600 ecr 1948263947], length 0
!02:27:25.203565 eno1  In  IP 192.168.178.106.65340 > 192.168.178.89.5005: Flags [R], seq 375693156, win 0, length 0
02:27:25.203659 docker0 Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [R], seq 375693156, win 0, length 0
02:27:25.203675 vetha9d3a9e Out IP 192.168.178.106.65340 > 172.17.0.3.5005: Flags [R], seq 375693156, win 0, length 0
02:27:47.386920 eno1  In  IP 192.168.178.106.65341 > 192.168.178.89.5005: Flags [S], seq 3518684815, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 2076954781 ecr 0,sackOK,eol], length 0
02:27:47.387052 docker0 Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [S], seq 3518684815, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 2076954781 ecr 0,sackOK,eol], length 0
02:27:47.387069 vetha9d3a9e Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [S], seq 3518684815, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 2076954781 ecr 0,sackOK,eol], length 0
02:27:47.387154 vetha9d3a9e P   IP 172.17.0.3.5005 > 192.168.178.106.65341: Flags [S.], seq 2450179614, ack 3518684816, win 65160, options [mss 1460,sackOK,TS val 3259177383 ecr 2076954781,nop,wscale 7], length 0
02:27:47.387176 docker0 In  IP 172.17.0.3.5005 > 192.168.178.106.65341: Flags [S.], seq 2450179614, ack 3518684816, win 65160, options [mss 1460,sackOK,TS val 3259177383 ecr 2076954781,nop,wscale 7], length 0
02:27:47.387199 eno1  Out IP 192.168.178.89.5005 > 192.168.178.106.65341: Flags [S.], seq 2450179614, ack 3518684816, win 65160, options [mss 1460,sackOK,TS val 3259177383 ecr 2076954781,nop,wscale 7], length 0
02:27:47.393879 eno1  In  IP 192.168.178.106.65341 > 192.168.178.89.5005: Flags [.], ack 1, win 2058, options [nop,nop,TS val 2076954788 ecr 3259177383], length 0
02:27:47.393879 eno1  In  IP 192.168.178.106.65341 > 192.168.178.89.5005: Flags [P.], seq 1:518, ack 1, win 2058, options [nop,nop,TS val 2076954788 ecr 3259177383], length 517
02:27:47.393977 docker0 Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [.], ack 1, win 2058, options [nop,nop,TS val 2076954788 ecr 3259177383], length 0
02:27:47.393995 vetha9d3a9e Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [.], ack 1, win 2058, options [nop,nop,TS val 2076954788 ecr 3259177383], length 0
02:27:47.394008 docker0 Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [P.], seq 1:518, ack 1, win 2058, options [nop,nop,TS val 2076954788 ecr 3259177383], length 517
02:27:47.394011 vetha9d3a9e Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [P.], seq 1:518, ack 1, win 2058, options [nop,nop,TS val 2076954788 ecr 3259177383], length 517
02:27:47.394139 vetha9d3a9e P   IP 172.17.0.3.5005 > 192.168.178.106.65341: Flags [.], ack 518, win 506, options [nop,nop,TS val 3259177390 ecr 2076954788], length 0
02:27:47.394159 docker0 In  IP 172.17.0.3.5005 > 192.168.178.106.65341: Flags [.], ack 518, win 506, options [nop,nop,TS val 3259177390 ecr 2076954788], length 0
02:27:47.394183 eno1  Out IP 192.168.178.89.5005 > 192.168.178.106.65341: Flags [.], ack 518, win 506, options [nop,nop,TS val 3259177390 ecr 2076954788], length 0
02:27:54.532205 eno1  In  IP 192.168.178.106.65341 > 192.168.178.89.5005: Flags [F.], seq 518, ack 1, win 2058, options [nop,nop,TS val 2076961922 ecr 3259177390], length 0
02:27:54.532294 docker0 Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [F.], seq 518, ack 1, win 2058, options [nop,nop,TS val 2076961922 ecr 3259177390], length 0
02:27:54.532309 vetha9d3a9e Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [F.], seq 518, ack 1, win 2058, options [nop,nop,TS val 2076961922 ecr 3259177390], length 0
02:27:54.532763 vetha9d3a9e P   IP 172.17.0.3.5005 > 192.168.178.106.65341: Flags [F.], seq 1, ack 519, win 506, options [nop,nop,TS val 3259184529 ecr 2076961922], length 0
02:27:54.532792 docker0 In  IP 172.17.0.3.5005 > 192.168.178.106.65341: Flags [F.], seq 1, ack 519, win 506, options [nop,nop,TS val 3259184529 ecr 2076961922], length 0
02:27:54.532830 eno1  Out IP 192.168.178.89.5005 > 192.168.178.106.65341: Flags [F.], seq 1, ack 519, win 506, options [nop,nop,TS val 3259184529 ecr 2076961922], length 0
02:27:54.535931 eno1  In  IP 192.168.178.106.65341 > 192.168.178.89.5005: Flags [.], ack 2, win 2058, options [nop,nop,TS val 2076961930 ecr 3259184529], length 0
02:27:54.536015 docker0 Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [.], ack 2, win 2058, options [nop,nop,TS val 2076961930 ecr 3259184529], length 0
02:27:54.536032 vetha9d3a9e Out IP 192.168.178.106.65341 > 172.17.0.3.5005: Flags [.], ack 2, win 2058, options [nop,nop,TS val 2076961930 ecr 3259184529], length 0
> sudo docker logs -f uptime-buddy-api
2024-10-23 02:05:37,221 - __main__ - INFO - Successfully connected to Uptime Kuma instance
2024-10-23 02:05:37,224 - __main__ - INFO - Starting the backend...
2024-10-23 02:05:37,225 - waitress - INFO - Serving on http://0.0.0.0:5005
schech1 commented 1 month ago

Hey. When you enter the backend and token in the app and click on "Test Backend" you should see a docker log that tells that the endpoint /status was accessed. This is what the app queries to get the status of the backend.

In the docker log you will see an entry every time an endpoint is accessed, therefore I believe the request never reaches the backend.

How is your setup? Do you expose the backend to the internet or you try it locally? Are you sure the entered backend url includes the port 5005?

FireIP commented 1 month ago

Thanks for the quick answer I originally exposed the backend to the internet and then locally for testing. After sleeping about it I probably made some stupid mistake moving from global to local.

FireIP commented 1 month ago

I found the issue it was a faulty nginx configuration for the exposed test and then I forgot to remove the s from https locally...

Thanks again for your quick response. The app works great.

schech1 commented 1 month ago

Great to hear 🙂 Let me know, when you experience any issues.