act28 / pia-openvpn-proxy

An Alpine Linux docker container running Privoxy and OpenVPN via Private Internet Access
19 stars 9 forks source link

Does not reconnect when connection drops #4

Closed cbrherms closed 4 years ago

cbrherms commented 4 years ago

Thanks for this container, finding it really useful.

One thing i have noticed though, is when the VPN connection drops, i.e. router reset or ISP timeout occurs, container either does not notice or does not reconnect, requiring a restart or recreate of the container.

Would i be possible to have a health check trying to resolve a known good dns entry, or pinging google dns etc and on fail attempt to restart the connection process?

act28 commented 4 years ago

You could try putting the following directives in your ovpn config, and see if that helps.

ping 10
ping-restart 30

https://openvpn.net/community-resources/reference-manual-for-openvpn-2-4/

cbrherms commented 4 years ago

Quite the long delay as missed the notification of a reply and didn't run in to any internet drops since... But, as an update, the above didn't seem to work in my case. It would instead try continuously reconnecting and i believe fail? No connection though via privoxy at least.

Fri May  1 16:31:19 2020 UDP link remote: [AF_INET]46.166.190.214:1197
Fri May  1 16:31:49 2020 [UNDEF] Inactivity timeout (--ping-restart), restarting
Fri May  1 16:31:49 2020 SIGUSR1[soft,ping-restart] received, process restarting
Fri May  1 16:31:54 2020 TCP/UDP: Preserving recently used remote address: [AF_INET]46.166.188.197:1197
Fri May  1 16:31:54 2020 UDP link local: (not bound)
Fri May  1 16:31:54 2020 UDP link remote: [AF_INET]46.166.188.197:1197
Fri May  1 16:32:24 2020 [UNDEF] Inactivity timeout (--ping-restart), restarting
Fri May  1 16:32:24 2020 SIGUSR1[soft,ping-restart] received, process restarting
Fri May  1 16:32:29 2020 TCP/UDP: Preserving recently used remote address: [AF_INET]46.166.138.143:1197
Fri May  1 16:32:29 2020 UDP link local: (not bound)
Fri May  1 16:32:29 2020 UDP link remote: [AF_INET]46.166.138.143:1197
Fri May  1 16:32:59 2020 [UNDEF] Inactivity timeout (--ping-restart), restarting
Fri May  1 16:32:59 2020 SIGUSR1[soft,ping-restart] received, process restarting
Fri May  1 16:33:04 2020 TCP/UDP: Preserving recently used remote address: [AF_INET]109.201.154.143:1197
Fri May  1 16:33:04 2020 UDP link local: (not bound)
Fri May  1 16:33:04 2020 UDP link remote: [AF_INET]109.201.154.143:1197
cbrherms commented 4 years ago

Okay, so it looks like the issue is due to "persist-tun" being in all pia downloaded configs by default. With that commented out,

ping 10
ping-restart 30

or

keepalive 10 30

works

act28 commented 4 years ago

Ah, yes. Since openvpn is running as root, it's safe to drop persist-tun. It's only needed if running as non-root user.

Marking as SOLVED.