io.netty.handler.timeout.WriteTimeoutException Java Examples

The following examples show how to use io.netty.handler.timeout.WriteTimeoutException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalInboudHandler.java    From one-net with Apache License 2.0 5 votes vote down vote up
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    if (cause instanceof WriteTimeoutException) {
    }
    this.oneNetClientContext.closeDirectly(clientSession);
    ctx.close();
}
 
Example #2
Source File: NettyRequestExecutor.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private Throwable decorateException(Throwable originalCause) {
    if (isAcquireTimeoutException(originalCause)) {
        return new Throwable(getMessageForAcquireTimeoutException(), originalCause);
    } else if (isTooManyPendingAcquiresException(originalCause)) {
        return new Throwable(getMessageForTooManyAcquireOperationsError(), originalCause);
    } else if (originalCause instanceof ReadTimeoutException) {
        return new IOException("Read timed out", originalCause);
    } else if (originalCause instanceof WriteTimeoutException) {
        return new IOException("Write timed out", originalCause);
    } else if (originalCause instanceof ClosedChannelException) {
        return new IOException(getMessageForClosedChannel(), originalCause);
    }

    return originalCause;
}
 
Example #3
Source File: ResponseHandler.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private Throwable wrapException(Throwable originalCause) {
    if (originalCause instanceof ReadTimeoutException) {
        return new IOException("Read timed out", originalCause);
    } else if (originalCause instanceof WriteTimeoutException) {
        return new IOException("Write timed out", originalCause);
    }

    return originalCause;
}
 
Example #4
Source File: HttpUploadHandler.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) {
  if (t instanceof WriteTimeoutException) {
    super.exceptionCaught(ctx, new UploadTimeoutException(path, contentLength));
  } else if (t instanceof TooLongFrameException) {
    super.exceptionCaught(ctx, new IOException(t));
  } else {
    super.exceptionCaught(ctx, t);
  }
}
 
Example #5
Source File: TcpSession.java    From PacketLib with MIT License 5 votes vote down vote up
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    String message = null;
    if(cause instanceof ConnectTimeoutException || (cause instanceof ConnectException && cause.getMessage().contains("connection timed out"))) {
        message = "Connection timed out.";
    } else if(cause instanceof ReadTimeoutException) {
        message = "Read timed out.";
    } else if(cause instanceof WriteTimeoutException) {
        message = "Write timed out.";
    } else {
        message = cause.toString();
    }

    this.disconnect(message, cause);
}
 
Example #6
Source File: HttpCacheClient.java    From bazel with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("FutureReturnValueIgnored")
private Channel acquireUploadChannel() throws InterruptedException {
  Promise<Channel> channelReady = eventLoop.next().newPromise();
  channelPool
      .acquire()
      .addListener(
          (Future<Channel> channelAcquired) -> {
            if (!channelAcquired.isSuccess()) {
              channelReady.setFailure(channelAcquired.cause());
              return;
            }

            try {
              Channel ch = channelAcquired.getNow();
              ChannelPipeline p = ch.pipeline();

              if (!isChannelPipelineEmpty(p)) {
                channelReady.setFailure(
                    new IllegalStateException("Channel pipeline is not empty."));
                return;
              }

              p.addFirst(
                  "timeout-handler",
                  new IdleTimeoutHandler(timeoutSeconds, WriteTimeoutException.INSTANCE));
              p.addLast(new HttpResponseDecoder());
              // The 10KiB limit was chosen arbitrarily. We only expect HTTP servers to respond
              // with an error message in the body, and that should always be less than 10KiB. If
              // the response is larger than 10KiB, HttpUploadHandler will catch the
              // TooLongFrameException that HttpObjectAggregator throws and convert it to an
              // IOException.
              p.addLast(new HttpObjectAggregator(10 * 1024));
              p.addLast(new HttpRequestEncoder());
              p.addLast(new ChunkedWriteHandler());
              synchronized (credentialsLock) {
                p.addLast(new HttpUploadHandler(creds, extraHttpHeaders));
              }

              if (!ch.eventLoop().inEventLoop()) {
                // If addLast is called outside an event loop, then it doesn't complete until the
                // event loop is run again. In that case, a message sent to the last handler gets
                // delivered to the last non-pending handler, which will most likely end up
                // throwing UnsupportedMessageTypeException. Therefore, we only complete the
                // promise in the event loop.
                ch.eventLoop().execute(() -> channelReady.setSuccess(ch));
              } else {
                channelReady.setSuccess(ch);
              }
            } catch (Throwable t) {
              channelReady.setFailure(t);
            }
          });

  try {
    return channelReady.get();
  } catch (ExecutionException e) {
    PlatformDependent.throwException(e.getCause());
    return null;
  }
}