Argo Tunnel fails to connect if origin isn't ready


#1

I have been using Argo Tunnel for a while now. When I first started exposing my origin application it worked great, the app was fresh and new and started super quick.

However, as my app (and its database) grew in size, it takes a little longer before it enters a state where it is ready to serve requests after a reboot.

What this generally means is that Argo comes up before the app is ready, and I get presented with the following in my log:

getsockopt: connection refused","level":"error","msg":"unable to connect to the origin","time"

That means Argo never actually starts, because it doesn’t think the source app is ready. It never re-attempts to connect which usually meant i had to manually log into the server and restart cloudflared.

I have temporarily fixed this by sleeping cloudflared on start for 30 seconds, but it may be worth implementing a “retry” period when cloudflared starts.

Just a thought :slight_smile:


#2

I had the same problem and solved it by modifying the cloudflared.service unit that gets created when installing argo tunnel as a system service. My server runs a nginx docker container so I modified cloudflared.server to wait until the docker service has started and then just set the restart directive to always so that the tunnel will connect once the container is running.

[Unit]
Description=Argo Tunnel
After=docker.service

[Service]
TimeoutStartSec=0
Type=notify
ExecStart=/usr/local/bin/cloudflared --config /etc/cloudflared/config.yml --origincert /etc/cloudflared/cert.pem --no-autoupdate
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

Hope that helps!


#3

Continuing the discussion from Argo Tunnel fails to connect if origin isn't ready:

[quote=“alrhos, post:2, topic:43059”]
multi-user.target
[/quote] juyoung