From 939adb1f316fd15d83145c7b82c13f00b4105ba4 Mon Sep 17 00:00:00 2001 From: Ted Xiao Date: Tue, 23 Feb 2016 09:44:44 +0800 Subject: [PATCH] allow user to adjust socket timeout --- src/main/java/hudson/remoting/Engine.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/hudson/remoting/Engine.java b/src/main/java/hudson/remoting/Engine.java index f28891c35..c6880cebe 100644 --- a/src/main/java/hudson/remoting/Engine.java +++ b/src/main/java/hudson/remoting/Engine.java @@ -388,7 +388,7 @@ private Socket connect(String host, String port) throws IOException, Interrupted // to interfere with normal operation. the main purpose of this is that when the other peer dies // abruptly, we shouldn't hang forever, and at some point we should notice that the connection // is gone. - s.setSoTimeout(30*60*1000); // 30 mins. See PingThread for the ping interval + s.setSoTimeout(SOCKET_TIMEOUT); // default is 30 mins. See PingThread for the ping interval if (isHttpProxy) { String connectCommand = String.format("CONNECT %s:%s HTTP/1.1\r\nHost: %s\r\n\r\n", host, port, host); @@ -561,7 +561,8 @@ public FileInputStream run() throws Exception { } }); } - + //a read() call on the SocketInputStream associated with underlying Socket will block for only this amount of time + static final int SOCKET_TIMEOUT = Integer.getInteger(Engine.class.getName()+".socketTimeout",30*60*1000); /** * @deprecated Use {@link JnlpProtocol#GREETING_SUCCESS}. */