You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/01/08 06:45:03 UTC

[GitHub] [rocketmq] yrg5101 commented on issue #3726: rocketmq client invokeSync: close socket because of timeout, 3000ms

yrg5101 commented on issue #3726:
URL: https://github.com/apache/rocketmq/issues/3726#issuecomment-1007897372


   > 可以先检查一下客户端到broker的网络情况
   
   谢谢回复,这样的我们这个broker是放在华为云上的, 提供公网访问, 外部的客户端通过公网访问broker,前期一直是好好的, 就这几点大面积的出现超时, 不是一个客户端出问题, 感觉是broker端出了问题, 但是看了端口,网络带宽都没有什么异常, 所有感觉没什么思路,期间修改了client的超时时间从3000ms到10000ms, 但是还是出问题
   
   定位代码:RemotingCommand response = this.invokeSyncImpl(channel, request, timeoutMillis - costTime);应该在这边抛的异常
   if (channel != null && channel.isActive()) {
               try {
                   doBeforeRpcHooks(addr, request);
                   long costTime = System.currentTimeMillis() - beginStartTime;
                   log.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++");
                   log.info("invokeSync: costTime is , {}ms", costTime);
                   System.out.println("++++++++++++++++++++++++++++++++++++++++++++++");
                   System.out.println("invokeSync: costTime is" + costTime +"ms");
                   if (timeoutMillis < costTime) {
                       throw new RemotingTimeoutException("invokeSync call timeout");
                   }
                   **RemotingCommand response = this.invokeSyncImpl(channel, request, timeoutMillis - costTime);**
                   doAfterRpcHooks(RemotingHelper.parseChannelRemoteAddr(channel), request, response);
                   return response;
               } catch (RemotingSendRequestException e) {
                   log.warn("invokeSync: send request exception, so close the channel[{}]", addr);
                   this.closeChannel(addr, channel);
                   throw e;
               } catch (RemotingTimeoutException e) {
                   if (nettyClientConfig.isClientCloseSocketIfTimeout()) {
                       this.closeChannel(addr, channel);
                       log.warn("invokeSync: close socket because of timeout, {}ms, {}", timeoutMillis, addr);
                   }
                   log.warn("invokeSync: wait response timeout exception, the channel[{}]", addr);
                   throw e;
               }
   
   
   
   
   
   try {
               final ResponseFuture responseFuture = new ResponseFuture(channel, opaque, timeoutMillis, null, null);
               this.responseTable.put(opaque, responseFuture);
               final SocketAddress addr = channel.remoteAddress();
               channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
                   @Override
                   public void operationComplete(ChannelFuture f) throws Exception {
                       if (f.isSuccess()) {
                           responseFuture.setSendRequestOK(true);
                           return;
                       } else {
                           responseFuture.setSendRequestOK(false);
                       }
   
                       responseTable.remove(opaque);
                       responseFuture.setCause(f.cause());
                       responseFuture.putResponse(null);
                       log.warn("send a request command to channel <" + addr + "> failed.");
                   }
               });
   
               **RemotingCommand responseCommand = responseFuture.waitResponse(timeoutMillis);
               if (null == responseCommand) {**
                   if (responseFuture.isSendRequestOK()) {
                       throw new RemotingTimeoutException(RemotingHelper.parseSocketAddressAddr(addr), timeoutMillis,
                           responseFuture.getCause());
                   } else {
                       **throw new RemotingSendRequestException(RemotingHelper.parseSocketAddressAddr(addr), responseFuture.getCause());**
                   }
               }


-- 
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: dev-unsubscribe@rocketmq.apache.org

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