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

tcp connection is not closed if websocket goes down #114

Closed
toewsar opened this issue Mar 21, 2023 · 9 comments · Fixed by #116
Closed

tcp connection is not closed if websocket goes down #114

toewsar opened this issue Mar 21, 2023 · 9 comments · Fixed by #116

Comments

@toewsar
Copy link

toewsar commented Mar 21, 2023

If the websocket connection closes the local tcp connection does not get informend and it looks like the connection the proxied port is still established.

Therefore the proxy should also close alle established connections on the local tcp side if the websocket connection breaks.

@reubenmiller
Copy link
Contributor

@toewsar do you happen to have an easy way to reproduce it? I’d say the fix will be relatively easy (as some kind of shutdown signal is probably missing), but just finding the right spot might be more difficult.

@toewsar
Copy link
Author

toewsar commented Mar 22, 2023

@reubenmiller it should possible to reproduce, by restarting the remote-access app in the device while a connection is running.

  1. Start the proxy in server mode
host$ c8ylp server ABCD --env-file .env -c ssh --port 22222
  1. Open a ssh connection
host$ ssh admin@localhost -p 22222
  1. Disconnect the device from websocket (e.g. by pulling the cable)
  2. You shoud see in the c8ylp output [c8ylp] INFO WebSocket Connection closed. Status: 1000 (NORMAL)
  3. The local ssh is still open, but shoudn't

@switschel
Copy link
Collaborator

@switschel
Copy link
Collaborator

It's also a question of expected behavior in server mode. In last version I expected that it runs forever, so on each disconnect of WS it tries to reconnect instead of terminating the whole proxy instance.

@toewsar
Copy link
Author

toewsar commented Mar 22, 2023

Every protocol that requires a specific handshake at the beginning and does not send keepalive frames won't work if the client doesn't get informed about the connection abort.

@switschel
Copy link
Collaborator

For that reason we have to discuss what's the best scenario on web socket disconnect is:

  1. Disconnecting the TCP client and shutting down the whole c8ylp instance - tcp-server is shutdown
  2. Disconnecting the TCP client and keep the c8ylp alive - tcp-server is accepting new connections

I would prefer the 2. option but only in server mode, so we cannot just run "shutdown" (option 1) but have to implement a new function "disconnect" which disconnects the client but keeps the server alive.

@toewsar
Copy link
Author

toewsar commented Mar 22, 2023

I would also prefer the 2. option.

switschel added a commit to switschel/cumulocity-remote-access-local-proxy that referenced this issue Mar 27, 2023
reubenmiller pushed a commit that referenced this issue Mar 27, 2023
@reubenmiller
Copy link
Contributor

reubenmiller commented Mar 27, 2023

@toewsar This should be fixed now in v2.4.1. Please let use know if this is not the case.

@toewsar
Copy link
Author

toewsar commented Mar 28, 2023

First tests were successful. Thank you.

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

Successfully merging a pull request may close this issue.

3 participants