You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/12/06 06:34:37 UTC

[GitHub] [servicecomb-java-chassis] five111 opened a new issue #2654: java-chassis可以设置tcp连接超时的时间吗

five111 opened a new issue #2654:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2654


   ### 背景如下 
   应用在现网跑了一段时间 偶现 
   io.netty.channel.connecttimeoutexception connection timed out 
   应该是tcp连接超时了 具体发送请求仅过去了1s 查看netty源码如下
   ```
   @Override
           public final void connect(
                   final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
               if (!promise.setUncancellable() || !ensureOpen(promise)) {
                   return;
               }
   
               try {
                   if (connectPromise != null) {
                       // Already a connect in process.
                       throw new ConnectionPendingException();
                   }
   
                   boolean wasActive = isActive();
                   if (doConnect(remoteAddress, localAddress)) {
                       fulfillConnectPromise(promise, wasActive);
                   } else {
                       connectPromise = promise;
                       requestedRemoteAddress = remoteAddress;
   
                       // Schedule connect timeout.
                       int connectTimeoutMillis = config().getConnectTimeoutMillis();
                       if (connectTimeoutMillis > 0) {
                           connectTimeoutFuture = eventLoop().schedule(new Runnable() {
                               @Override
                               public void run() {
                                   ChannelPromise connectPromise = AbstractNioChannel.this.connectPromise;
                                   if (connectPromise != null && !connectPromise.isDone()
                                           && connectPromise.tryFailure(new ConnectTimeoutException(
                                                   "connection timed out: " + remoteAddress))) {
                                       close(voidPromise());
                                   }
                               }
                           }, connectTimeoutMillis, TimeUnit.MILLISECONDS);
                       }
   
                       promise.addListener(new ChannelFutureListener() {
                           @Override
                           public void operationComplete(ChannelFuture future) throws Exception {
                               if (future.isCancelled()) {
                                   if (connectTimeoutFuture != null) {
                                       connectTimeoutFuture.cancel(false);
                                   }
                                   connectPromise = null;
                                   close(voidPromise());
                               }
                           }
                       });
                   }
               } catch (Throwable t) {
                   promise.tryFailure(annotateConnectException(t, remoteAddress));
                   closeIfClosed();
               }
           }
   ```
   netty 的默认配置应该是 30s  
   ```
   int connectTimeoutMillis = config().getConnectTimeoutMillis();
    @Override
   public int getConnectTimeoutMillis() {
           return connectTimeoutMillis;
   }
   private volatile int connectTimeoutMillis = DEFAULT_CONNECT_TIMEOUT;
   private static final int DEFAULT_CONNECT_TIMEOUT = 30000;
   ```
   请问是否是java-chassis做了一层配置 ,如果是 该如何修改这个超时时间


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2654: java-chassis可以设置tcp连接超时的时间吗

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2654:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2654#issuecomment-988577976


   网络条件不好的情况下,可以考虑适当调到这个参数。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #2654: java-chassis可以设置tcp连接超时的时间吗

Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #2654:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2654#issuecomment-988577976


   网络条件不好的情况下,可以考虑适当调大这个参数。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] five111 edited a comment on issue #2654: java-chassis可以设置tcp连接超时的时间吗

Posted by GitBox <gi...@apache.org>.
five111 edited a comment on issue #2654:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2654#issuecomment-986732861


   经过阅读源码
   ```
    public static int getConnectionTimeoutInMillis() {
       return DynamicPropertyFactory.getInstance()
           .getIntProperty("servicecomb.rest.client.connection.timeoutInMillis", 1000)
           .get();
     }
   ```
   java-chassis是通过这个参数去配置的,当前这个参数在文档是看不见的。
   请问是不希望用户修改吗,如果修改会有什么隐藏bug吗 这个时间似乎会记录到408的超时时间里去 ?
   另外连接超时是否可以加入到重试机制里去?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] five111 commented on issue #2654: java-chassis可以设置tcp连接超时的时间吗

Posted by GitBox <gi...@apache.org>.
five111 commented on issue #2654:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2654#issuecomment-986732861


   经过阅读源码
   ```
    public static int getConnectionTimeoutInMillis() {
       return DynamicPropertyFactory.getInstance()
           .getIntProperty("servicecomb.rest.client.connection.timeoutInMillis", 1000)
           .get();
     }
   ```
   java-chassis是通过这个参数去配置的,当前这个参数在文档是看不见的。
   请问是不希望用户修改吗?建议值就是1s吗?
   另外连接超时是否可以加入到重试机制里去?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] five111 closed issue #2654: java-chassis可以设置tcp连接超时的时间吗

Posted by GitBox <gi...@apache.org>.
five111 closed issue #2654:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2654


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org