mirror of
https://github.com/dromara/hertzbeat.git
synced 2026-09-17 09:40:58 +00:00
[bugfix] fix wrong http user-agent content (#2996)
This commit is contained in:
+14
-1
@@ -144,12 +144,25 @@ public class CommonHttpClient {
|
||||
ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(1, threadFactory);
|
||||
scheduledExecutor.scheduleWithFixedDelay(() -> {
|
||||
connectionManager.closeExpiredConnections();
|
||||
connectionManager.closeIdleConnections(100, TimeUnit.SECONDS);
|
||||
connectionManager.closeIdleConnections(40, TimeUnit.SECONDS);
|
||||
}, 40L, 40L, TimeUnit.SECONDS);
|
||||
|
||||
// shutdown hook
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(CommonHttpClient::close));
|
||||
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public static CloseableHttpClient getHttpClient() {
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public static void close() {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (Exception e) {
|
||||
log.error("close http client error", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-7
@@ -25,7 +25,7 @@ public interface NetworkConstants {
|
||||
|
||||
String KEEP_ALIVE = "Keep-Alive";
|
||||
|
||||
String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36\")";
|
||||
String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36";
|
||||
|
||||
String IPV6 = "ipv6";
|
||||
|
||||
@@ -59,14 +59,8 @@ public interface NetworkConstants {
|
||||
int READ_TIME_OUT = 6 * 1000;
|
||||
int WRITE_TIME_OUT = 6 * 1000;
|
||||
int CONNECT_TIME_OUT = 6 * 1000;
|
||||
int CHUNK_SIZE = 8196;
|
||||
int MAX_IDLE_CONNECTIONS = 20;
|
||||
int KEEP_ALIVE_TIMEOUT = 30 * 1000;
|
||||
int HTTP_CLIENT_CONNECTION_MANAGER_MAX_PER_ROUTE = 20;
|
||||
int HTTP_CLIENT_CONNECTION_MANAGER_MAX_TOTAL = 20;
|
||||
int HTTPCLIENT_KEEP_ALIVE_DURATION = 30 * 1000;
|
||||
int HTTP_CLIENT_CONNECTION_MANAGER_CLOSE_WAIT_TIME_MS = 1000;
|
||||
int HTTP_CLIENT_CONNECTION_MANAGER_CLOSE_IDLE_TIME_S = 30;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user