Skip to content

Commit

Permalink
[SCB-2684]fix idle time out and keep alive timeout not properly set p…
Browse files Browse the repository at this point in the history
…roblem (apache#3346)
  • Loading branch information
liubao68 authored and lbc97 committed Feb 21, 2023
1 parent 116aaec commit 5061d6f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ public int getMaxHeaderSize() {

@Override
public int getKeepAliveTimeout() {
return HttpClientOptions.DEFAULT_KEEP_ALIVE_TIMEOUT;
int result = getIdleTimeoutInSeconds();
if (result > 1) {
return result - 1;
}
return result;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public int getMaxHeaderSize() {

@Override
public int getKeepAliveTimeout() {
return TransportClientConfig.getConnectionIdleTimeoutInSeconds();
return TransportClientConfig.getConnectionKeepAliveTimeoutInSeconds();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ public static boolean getConnectionKeepAlive() {
.get();
}

public static int getConnectionKeepAliveTimeoutInSeconds() {
int result = DynamicPropertyFactory.getInstance()
.getIntProperty("servicecomb.rest.client.connection.keepAliveTimeoutInSeconds",
-1)
.get();
if (result >= 0) {
return result;
}
result = getConnectionIdleTimeoutInSeconds();
if (result > 1) {
return result - 1; // a bit shorter than ConnectionIdleTimeoutInSeconds
}
return result;
}

public static boolean getConnectionCompression() {
return DynamicPropertyFactory.getInstance()
.getBooleanProperty("servicecomb.rest.client.connection.compression",
Expand Down

0 comments on commit 5061d6f

Please sign in to comment.