java java中JSch库中Session和Channel的默认超时时间是多少
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28038747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the default timeout for Session and Channel in JSch library in java
提问by Adon Smith
Does anyone know the default timeout for Session and Channel.
有谁知道 Session 和 Channel 的默认超时。
session.connect();
channel.connect();
I am going through the document but it doesn't explicitly say what is the default timeout ?
我正在浏览文档,但它没有明确说明默认超时是多少?
回答by Martin Prikryl
For the Channel
, the default timeout seems to be 20 seconds.
对于Channel
,默认超时似乎是 20 秒。
See the implementation of the Channel.sendChannelOpen()
.
请参阅Channel.sendChannelOpen()
.
The timeout here defines, how long will the connect()
wait for a response to open channel request. I'd say that the name of the method is confusing, it should be open()
. You are not connecting anywhere (the session is already open).
这里的超时定义了connect()
等待响应打开通道请求的时间。我会说该方法的名称令人困惑,它应该是open()
. 您没有在任何地方连接(会话已经打开)。
For the Session
, the default timeout is set using the setTimeout()
method. If not set, the default default is 0, what means "infinite". Though there's always some last resort timeout on an OS-level.
对于Session
,使用setTimeout()
方法设置默认超时。如果没有设置,默认默认为0,即“无限”的意思。尽管在操作系统级别上总是有一些不得已的超时。
The timeout here defines:
这里的超时定义:
- How long will the
connect()
wait for the socket to open.
Though this defines an upper limit only, to define a lower limit, see JSch session timeout limit. - Timeout for all future "reads" from the socket. See the
Socket.SetSoTimeout
- It also affects a connection to a proxy, if there's any.
connect()
等待套接字打开需要多长时间。
虽然这仅定义了上限,但要定义下限,请参阅JSch session timeout limit。- 所有未来从套接字“读取”的超时。见
Socket.SetSoTimeout
- 如果有的话,它也会影响到代理的连接。