erebe / wstunnel

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

thread blocked indefinitely in an MVar operation #135

Closed Arash-So closed 1 year ago

Arash-So commented 1 year ago

Every few hours I get this error on the client side and tunnel goes down until I run the command again.

Client# /root/wstunnel-x64-linux -v -u --udpTimeoutSec 300 --websocketPingFrequencySec 10 -L 0.0.0.0:<port>:127.0.0.1:<port> wss://<ip>:<port>

Server# /root/wstunnel-x64-linux --server wss://0.0.0.0:<port> -r 127.0.0.1:<port>

Error on the client every few hours: wstunnel-x64-linux: thread blocked indefinitely in an MVar operation

sindy39 commented 1 year ago

I confirm this behaviour even without the -v --udpTimeoutSec 300 --websocketPingFrequencySec 10 parameters and with forward-to address different from 127.0.0.1, and in both cases I've noticed so far, it took much less than an hour to happen. In fact, a constant bi-directional load of about 1 Mbit/s kills it almost instantly (after a few seconds), which happens to be the bandwidth of the uplink in my test environment. So my assumption is that it is related to loss of transport packets in client->server direction (in server->client one, bandwidth exhaustion does not cause the crash).

So @Arash-So , the workaround might be to throttle the payload traffic before entering the client, to avoid overloading the uplink with transport packets.

erebe commented 1 year ago

Hello,

Thank you for reporting it. This issue with UDP is normally handled https://github.com/erebe/wstunnel/blob/master/src/Protocols.hs#L96 , as indeed as you mention @sindy39 this can happen when packets are dropped between client and server or the client UDP stream die.

I need to look why the catch is not handling the case anymore on latest version. I will try to take the time during end of the month.

rajaeem commented 1 year ago

Hello, @erebe The " wstunnel: thread blocked indefinitely in an MVar operation" also exists in the previous version 4.0.

Arash-So commented 1 year ago

Thank you sindy39 and erebe. Right now I'm using Monit as a workaround to check on the client process every 5 seconds and re-start it, in case it exists with the error. It's been quite okay and users usually don't feel the drop.

erebe commented 1 year ago

Hi back,

Can you use the binaries from this pre-release and let me know if you still encounter the issue https://github.com/erebe/wstunnel/releases/tag/v5.0

I manage to reproduce the issue and this should fix it, but would like your feedback before releasing it

Arash-So commented 1 year ago

Hi erebe, looks pretty stable and no issue so far. Thank you for the fix and great job!!

erebe commented 1 year ago

Ok perfect then :)

Thank you for having testing it !