erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
BSD 3-Clause "New" or "Revised" License
4.19k stars 363 forks source link

Reconnect on error #291

Open kostanakis opened 3 months ago

kostanakis commented 3 months ago

Is it possible to add an option to force reconnect to server in case of error/connection temporary issues or so on? In my case, OpenVPN server drops connection with os error 10054 in case of authentication failure, and I have to stop/start wstunnel client manually. I'd like that wstunnel will try to reconnect, maybe with adjustable cooldown, so end user won't care about wstunnel, just run batch file and leave it alone.

nxtreaming commented 3 months ago

I alse faced the same error.

I think it is caused by the network switch from network A to network B , such as when switch from homework to office network .

the connection pool from network A will fail to work forever in network B, the only way to fix this issue is "restart the wstunnel client"

erebe commented 3 months ago

Hello,

It is not possible to fix this at wstunnel level. Check this answer for a more detailed explanation https://github.com/erebe/wstunnel/issues/163#issuecomment-2102274886

The only solution, is for your OpenVPN to try to reconnect when the connection is closed. Wstunnel client will re-open a new connection.

johnnyd-78 commented 1 week ago

And what about error Cannot read from UDP server. Closing server: Remote host forcely disconnect (os error 10054) when I just use Disconnect in OpenVPN? No network issues I just disconnecting. After it OpenVPN can't connect again, only after wstunnel app restarting. It's not possible to fix too?

erebe commented 6 days ago

Would you mind describing the issue? Not sure what does imply disconnecting openvpn, nor the setup involved.

johnnyd-78 commented 6 days ago

Disconnect menu item in OpenVPN GUI (RMB on sign in tray - (OVPN Profile Name) - Disconnect). After it a recieve 10054 error and can't connect anymore until restart wstunnel. Yes. it grab seconds but... very hard to explain to other users why they must do it constantly. But if no some lifehack, I will to try )

erebe commented 6 days ago

How do you start the clients and server ?

johnnyd-78 commented 6 days ago

Server - ExecStart=/usr/local/bin/wstunnel server wss://[::]:443 --restrict-to 5.XX.XXX.XX:753 Client - wstunnel client wss://5.XX.XXX.XX:443 -L udp://1212:5.XX.XXX.XX:753?timeout_sec=0 --tls-sni-override videocatch.lol

erebe commented 6 days ago

You can try to set a keepalive/hearthbeat of 20sec on your openvpn client and remove timeout_sec=0 in the wstunnel client command line. The tunnel should close after detecting inactivity.

If that does not work, i will try to check when i get back from vacation.

Let me know.

johnnyd-78 commented 6 days ago

No, it's don't solve the problem because [2m2024-09-26T19:20:58.321458Z←[0m ←[31mERROR←[0m ←[2mwstunnel::protocols::udp::server←[0m←[2m:←[0m Cannot read from UDP server. Closing server: (Don't know how it translate to english, "Remote host forcedly interrupts connection" may be) (os error 10054) Local UDP Server (127.0.0.1:1212) closed, as I understood. OpenVPN Client haven't place for connecting to anymore. Only restarting of wstunnel helps