erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Other
3.17k stars 287 forks source link

[windows] Client crashes after connection close #227

Closed hanjo closed 1 month ago

hanjo commented 2 months ago

Hi,

Describe the bug To tunnel WireGuard, I'm starting the client like so: .\wstunnel.exe client -L 'udp://51820:192.168.1.1:51820?timeout_sec=0' wss://192.168.1.221:443

Connection works fine. When I terminate the Wireguard connection, I can reconnect when I try it after a few seconds. If I wait for a bit, I'm receiving an error message on the client end:

2024-02-08T19:21:53.304550Z  INFO wstunnel::udp: Starting UDP server listening cnx on 127.0.0.1:51820 with cnx timeout of 0s
2024-02-08T19:22:05.335432Z  INFO wstunnel::udp: New UDP connection from 127.0.0.1:57732
2024-02-08T19:22:05.360856Z  INFO wstunnel::tcp: Opening TCP connection to 192.168.1.221:443
2024-02-08T19:22:05.404362Z  INFO wstunnel::tls: Doing TLS handshake using sni IpAddress(192.168.1.221) with the server 192.168.1.221:443
2024-02-08T19:22:16.460025Z  INFO wstunnel::udp: New UDP connection from 127.0.0.1:50675
2024-02-08T19:22:16.482888Z  INFO wstunnel::tcp: Opening TCP connection to 192.168.1.221:443
2024-02-08T19:22:16.495257Z  INFO wstunnel::tls: Doing TLS handshake using sni IpAddress(192.168.1.221) with the server 192.168.1.221:443
2024-02-08T19:22:40.173788Z ERROR wstunnel::udp: Cannot read from UDP server. Closing server: An existing connection was forcibly closed by the remote host. (os error 10054)

At this point Wireguard cannot connect any more. Restarting the client fixes the problem.

To Reproduce Run wstunnel, connect wireguard, disconnect wireguard, wait, try reconnecting wireguard

Expected behavior After disconnecting, wstunnel can accept new connections even after remote host closure.

Screenshots N/A

Desktop (please complete the following information):

Additional context This does only seem to be happening with the native Windows version, but not when running wstunnel inside WSL.

nxtreaming commented 2 months ago

try to keeplive the connection.

erebe commented 2 months ago

Hello, I will to look into, I keep you in touch.

At first glance

 Cannot read from UDP server. Closing server: An existing connection was forcibly closed by the remote host. (os error 10054)

this message means to me that it is the OS that closed the socket of the UDP server. If you a security/antivirus software on your machine it may be the cause.

Will try to rep-roduce the issue in any-case

hanjo commented 2 months ago

Well, this is a corporate device, so besides Windows Defender there might be more "security" on it. If you cannot reproduce it, maybe it is one of those. I'm happy to debug this on my device, if you can provide instructions.

erebe commented 2 months ago

I tried to reproduce the issue on my windows, but it works as expected for me :'(

Regarding how to debug that, I don't have much clue, as I don't use widows much. Maybe if you have some system/activity logs you can find something

erebe commented 1 month ago

Should be fixed in 9.2.5, but regarding the why the original issue arise, it is still unclear to me

kociubin commented 1 week ago

This is still happening for me in v9.3.0. Same error and symptoms as described in the OP.

I tried both: wstunnel_9.3.0_windows_386.tar.gz and wstunnel_9.3.0_windows_amd64.tar.gz. Issue still happening.

I tried disabling Windows built in Real-Time Virus Protection. Issue still happening.

FWIW, I'm on Windows ARM inside a VMware Fusion VM (although I doubt think this makes a difference)