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

It's better to add "timeout" option #78

Closed
tczf1128 opened this issue Oct 13, 2015 · 12 comments
Closed

It's better to add "timeout" option #78

tczf1128 opened this issue Oct 13, 2015 · 12 comments
Milestone

Comments

@tczf1128
Copy link

@tczf1128 tczf1128 commented Oct 13, 2015

gotty exit if no client connect to it

@yudai
Copy link
Owner

@yudai yudai commented Oct 13, 2015

Hi, could you describe your use case that needs timeout?

@yudai yudai added the status/triage label Oct 13, 2015
@tczf1128
Copy link
Author

@tczf1128 tczf1128 commented Oct 14, 2015

I use gotty with docker exec -it DOCKER_ID /bin/bash to show the terminal of container, then users can access to the container, and if no one connect it in 10 minutes, the gotty should exit

@yudai yudai modified the milestones: v0.1.0, icebox Oct 14, 2015
@yudai
Copy link
Owner

@yudai yudai commented Oct 14, 2015

Thanks.

I feel like it's a bit special use case, so let me keep this issue open to collect the same request from others.

@tczf1128
Copy link
Author

@tczf1128 tczf1128 commented Oct 14, 2015

Thanks

@wagnersza
Copy link

@wagnersza wagnersza commented May 13, 2016

+1 the same case

@zyfdegh
Copy link
Contributor

@zyfdegh zyfdegh commented Jul 28, 2016

+1 almost the same case. I need timeout option too. Quit command is also OK. I hacked gotty and use it parallel to call command. In this way, it supports mutilple connections.

@zyfdegh
Copy link
Contributor

@zyfdegh zyfdegh commented Aug 14, 2016

I figured out a solution, but it's not perfect so far.
I set a count down timer when each connection is established. It will do the following.

  1. The timeout interval is set when you run gotty like gotty -w --timeout=60 <cmd>.
  2. The left time is decreasing 1 every second since the connection is established. If user has no operation on the gotty web page, it will count down to 0 and will trigger a function named boom which will cause disconnection.
  3. The left time will be set to init value if the user has typed anything on gotty web page. To say technically, function Rewind() will be called inside processReceive() and processSend(). The Rewind() function will set the left time to initial value(the one in gotty command line). The timer will count down again and do same thing in step 2.
    It works like a old-fashioned stopwatch.

The issue is, when I run command like sleep 80 or start a long-run programme like top. It will disconnect when timeout. This bothers in some cases.

@zyfdegh
Copy link
Contributor

@zyfdegh zyfdegh commented Aug 14, 2016

PR is in #115 . It differ a bit as @tczf1128 descripbed the issue. Gotty will not exit when timeout, but the cmd will exit and gotty web page shows a Connection closed label.

@oneumyvakin
Copy link

@oneumyvakin oneumyvakin commented Oct 16, 2016

+1 I need timeout to free TCP port for further connections.
My case is multiple GoTTY instances running on one server in a specific port range, I'd like to use timeout to free used ports and server resources.

@oneumyvakin
Copy link

@oneumyvakin oneumyvakin commented Oct 16, 2016

@zyfdegh Thanks for your work and the PR. It's possible to make optionally GoTTY exit/no exit behaviour? Maybe one more command line option?

@zyfdegh
Copy link
Contributor

@zyfdegh zyfdegh commented Oct 17, 2016

@oneumyvakin View my fork on github.com/zyfdegh/gotty, it supports --timeout option. But I modified some source codes, so gotty will work a bit differently.

@yudai
Copy link
Owner

@yudai yudai commented Jan 9, 2017

Added --timeout option :)

@yudai yudai closed this May 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.