Skip to content
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

Reconnect on error #291

Open
kostanakis opened this issue Jun 8, 2024 · 12 comments
Open

Reconnect on error #291

kostanakis opened this issue Jun 8, 2024 · 12 comments

Comments

@kostanakis
Copy link

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
Copy link

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
Copy link
Owner

erebe commented Jun 9, 2024

Hello,

It is not possible to fix this at wstunnel level. Check this answer for a more detailed explanation #163 (comment)

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
Copy link

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
Copy link
Owner

erebe commented Sep 26, 2024

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

@johnnyd-78
Copy link

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
Copy link
Owner

erebe commented Sep 26, 2024

How do you start the clients and server ?

@johnnyd-78
Copy link

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
Copy link
Owner

erebe commented Sep 26, 2024

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
Copy link

johnnyd-78 commented Sep 26, 2024

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

@CyberShadow
Copy link

I see there is an option to periodically send a WebSockets ping frame. Is there an option to disconnect the tunnel if a pong is not received in some time? I think that should work well when tunneling UDP VPNs like Wireguard.

@erebe
Copy link
Owner

erebe commented Nov 3, 2024

@CyberShadow it is done autmatically if there 3 un-answered ping. The tunnel is going to close
https://github.com/erebe/wstunnel/blob/main/src/tunnel/transport/websocket.rs#L103

@CyberShadow
Copy link

Thanks! I think that bit is missing from the documentation.

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

5 participants