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

Allow setting timeouts for connection #11

Open
belak opened this issue Feb 3, 2017 · 7 comments
Open

Allow setting timeouts for connection #11

belak opened this issue Feb 3, 2017 · 7 comments

Comments

@belak
Copy link
Collaborator

belak commented Feb 3, 2017

Specifically for the handshake, requesting a session, starting a command, and connection closing.

@progrium
Copy link
Contributor

progrium commented Feb 3, 2017

Do you have any example of libraries that let you specify all the possible timeouts? Usually there is a high level timeout or two, but SSH has a lot of ones as you mention. Perhaps a Timeout struct than can be passed into our server object.

@belak
Copy link
Collaborator Author

belak commented Feb 3, 2017

I don't have any public examples. This comes from our config struct though (all the ones we support internally):

	// HandshakeTimeout is the amount of time allowed between connecting and
	// successful auth.
	HandshakeTimeout time.Duration

	// NewChannelTimeout is the amount of time allowed between auth and making
	// the first valid channel.
	NewChannelTimeout time.Duration

	// ChannelRequestTimeout is the amount of time allowed between creating a
	// channel and making the first valid request.
	ChannelRequestTimeout time.Duration

	// ConnectionCloseTimeout is the amount of time allowed between when the
	// command finishes running and the connection is forcefully closed.
	ConnectionCloseTimeout time.Duration

@belak
Copy link
Collaborator Author

belak commented Feb 3, 2017

I realize this won't be used by everyone, or even most people, so I'd be happy to do the work to support most of the features I'm proposing.

@progrium
Copy link
Contributor

progrium commented Feb 3, 2017

What do you think of wrapping these in a struct:

type Timeouts struct {
	// HandshakeTimeout is the amount of time allowed between connecting and
	// successful auth.
	Handshake time.Duration

	// NewChannelTimeout is the amount of time allowed between auth and making
	// the first valid channel.
	NewChannel time.Duration

	// ChannelRequestTimeout is the amount of time allowed between creating a
	// channel and making the first valid request.
	ChannelRequest time.Duration

	// ConnectionCloseTimeout is the amount of time allowed between when the
	// command finishes running and the connection is forcefully closed.
	ConnectionClose time.Duration
}

@belak
Copy link
Collaborator Author

belak commented Feb 3, 2017

That works for me. Other notes from our discussion:

@aderouineau
Copy link

I have created a pull request to support handshake timeout: #204

@bavarianbidi
Copy link

I've stumbled over this issue here and i'm wondering if it's also a valid use-case to have a timeout where the server will shutdown if no connection is established within the defined timeout duration?

more context:

we are using https://github.com/owenthereal/upterm which spawn a sshServer (in gliderlabs/ssh speech) on demand.
We are using this in combination with github runners to be able so ssh into a runner, if needed.
At the moment we have written a shell wrapper around upterm to terminate the process if no connection got established.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants