erebe / wstunnel

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

In normal use server log contains "error while reading from tunnel rx websocket close" #241

Closed chibbert closed 1 month ago

chibbert commented 1 month ago

Describe the bug We've started looking to use wstunnel for our use case and love what it can do, thanks for a great project!

When creating a simple local setup to test wstunnel for our use case (reverse tunnel) I noticed the following error in the logs:

ERROR tunnel{peer="[::ffff:127.0.0.1]:48462" id="018e3c87-7d3a-7419-b6e6-850d3ce1bf4d" remote="[::]:9001"}: wstunnel::tunnel::transport::io: error while reading from tunnel rx websocket close

To Reproduce Steps to reproduce the behavior:

# Start python http server:
python -m http.server 8001

# Start client end of wstunnel:
wstunnel client -R tcp://[::]:9001:localhost:8001 wss://127.0.0.1:8443

# Start server end of wstunnel:
wstunnel server wss://[::]:8443

# Curl via wstunnel:
curl localhost:9001

# You will get a sucessful 200 response:
curl localhost:9001
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Directory listing for /</title>
</head>
<body>
<h1>Directory listing for /</h1>
<hr>
<ul>
<li><a href="edge_device_1">edge_device_1</a></li>
</ul>
<hr>
</body>
</html>

However the server side logs show an error:

2024-03-14T10:46:18.222759Z  INFO wstunnel::embedded_certificate: Loading embedded tls certificate
2024-03-14T10:46:18.222783Z  INFO wstunnel::embedded_certificate: Loading embedded tls private key
2024-03-14T10:46:18.222968Z  INFO wstunnel: Starting wstunnel server v9.2.3 with config WsServerConfig { socket_so_mark: None, bind: [::]:8443, restrict_to: None, restrict_http_upgrade_path_prefix: None, websocket_ping_frequency: None, timeout_connect: 10s, websocket_mask_frame: false, tls: true }
2024-03-14T10:46:18.222988Z  INFO wstunnel::tunnel::server: Starting wstunnel server listening on [::]:8443
2024-03-14T10:46:19.741277Z  INFO wstunnel::tunnel::server: Accepting connection
2024-03-14T10:46:19.741372Z  INFO tunnel{peer="[::ffff:127.0.0.1]:45908"}: wstunnel::tunnel::server: Doing TLS handshake
2024-03-14T10:46:19.743109Z  INFO tunnel{peer="[::ffff:127.0.0.1]:45908" id="018e3c91-e068-7db1-aa71-6c85c6943de0" remote="[::]:9001"}: wstunnel::tcp: Starting TCP server listening cnx on [::]:9001
2024-03-14T10:46:21.143749Z  INFO tunnel{peer="[::ffff:127.0.0.1]:45908" id="018e3c91-e068-7db1-aa71-6c85c6943de0" remote="[::]:9001"}: wstunnel::tunnel::server: connected to ReverseTcp [::]:9001
2024-03-14T10:46:21.144184Z  INFO wstunnel::tunnel::server: Accepting connection
2024-03-14T10:46:21.144234Z  INFO tunnel{peer="[::ffff:127.0.0.1]:45912"}: wstunnel::tunnel::server: Doing TLS handshake
2024-03-14T10:46:21.144985Z ERROR tunnel{peer="[::ffff:127.0.0.1]:45908" id="018e3c91-e068-7db1-aa71-6c85c6943de0" remote="[::]:9001"}: wstunnel::tunnel::transport::io: error while reading from tunnel rx websocket close
2024-03-14T10:46:21.145017Z  INFO tunnel{peer="[::ffff:127.0.0.1]:45908" id="018e3c91-e068-7db1-aa71-6c85c6943de0" remote="[::]:9001"}: wstunnel::tunnel::transport::io: Closing local <= remote tunnel
2024-03-14T10:46:21.145067Z  INFO tunnel{peer="[::ffff:127.0.0.1]:45908" id="018e3c91-e068-7db1-aa71-6c85c6943de0" remote="[::]:9001"}: wstunnel::tunnel::transport::io: Closing local => remote tunnel

Expected behavior I would like to understand whether an error is really occurring or whether the log should be at INFO/DEBUG level instead?

Screenshots image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

erebe commented 1 month ago

Hello, Yeah, no worries, this is kind of the normal behavior, it just means that the connection has been closed while trying to read from it. I have set it as error, as it can be a normal TCP close or a hard reset. But it can be a warn or debug log indeed.

erebe commented 1 month ago

feel free to re-open if needed