Skip to content

Commit 39f8334

Browse files
author
Javen
committed
Connection timeout default change to 5s
1 parent 7d5dc91 commit 39f8334

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/cn/jpush/api/common/IHttpClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public interface IHttpClient {
1616
public static final String METHOD_GET = "GET";
1717

1818
//设置连接超时时间
19-
public final int DEFAULT_CONNECTION_TIMEOUT = (20 * 1000); // milliseconds
19+
public final int DEFAULT_CONNECTION_TIMEOUT = (5 * 1000); // milliseconds
2020

2121
//设置读取超时时间
22-
public final int DEFAULT_SOCKET_TIMEOUT = (30 * 1000); // milliseconds
22+
public final int DEFAULT_READ_TIMEOUT = (30 * 1000); // milliseconds
2323

2424
public ResponseWrapper sendGet(String url, String params, String authCode);
2525

src/cn/jpush/api/common/NativeHttpClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public ResponseWrapper sendRequest(String url, String content, String method, St
5656
URL aUrl = new URL(url);
5757
conn = (HttpURLConnection) aUrl.openConnection();
5858
conn.setConnectTimeout(DEFAULT_CONNECTION_TIMEOUT);
59-
conn.setReadTimeout(DEFAULT_SOCKET_TIMEOUT);
59+
conn.setReadTimeout(DEFAULT_READ_TIMEOUT);
6060
conn.setUseCaches(false);
6161
conn.setRequestMethod(method);
6262
conn.setRequestProperty("User-Agent", JPUSH_USER_AGENT);
@@ -135,7 +135,7 @@ public ResponseWrapper sendRequest(String url, String content, String method, St
135135

136136
} catch (SocketTimeoutException e) {
137137
wrapper.exceptionString = e.getMessage();
138-
LOG.error("Request timeout. Retry later.", e);
138+
LOG.error("Read timeout. Retry later.", e);
139139
} catch (ConnectException e) {
140140
wrapper.exceptionString = e.getMessage();
141141
LOG.error("Connnect error. Retry later.", e);
@@ -147,7 +147,7 @@ public ResponseWrapper sendRequest(String url, String content, String method, St
147147
LOG.error("IO error. Retry later.", e);
148148
} catch (Exception e) {
149149
wrapper.exceptionString = e.getMessage();
150-
LOG.error("Unknown exception. ", e);
150+
LOG.error("Unknown exception - Unexpected. Please contact us.", e);
151151
} finally {
152152
if (null != out) {
153153
try {

0 commit comments

Comments
 (0)