项目:elasticsearch_my
文件:Netty4HttpServerTransport.java
protected void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (cause instanceof ReadTimeoutException) {
if (logger.isTraceEnabled()) {
logger.trace("Connection timeout [{}]",ctx.channel().remoteAddress());
}
ctx.channel().close();
} else {
if (!lifecycle.started()) {
// ignore
return;
}
if (!NetworkExceptionHelper.isCloseConnectionException(cause)) {
logger.warn(
(Supplier<?>) () -> new ParameterizedMessage(
"caught exception while handling client http traffic,closing connection {}",ctx.channel()),cause);
ctx.channel().close();
} else {
logger.debug(
(Supplier<?>) () -> new ParameterizedMessage(
"caught exception while handling client http traffic,cause);
ctx.channel().close();
}
}
}
项目:mqttserver
文件:MqttMessageHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable e)
throws Exception {
try {
if (e.getCause() instanceof ReadTimeoutException) {
ctx.write(PINGRESP).addListener(
ChannelFutureListener.CLOSE_ON_FAILURE);
} else {
ctx.channel().close();
}
} catch (Throwable t) {
t.printStackTrace();
ctx.channel().close();
}
e.printStackTrace();
}
项目:NioSmtpClient
文件:ResponseHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (cause instanceof ReadTimeoutException) {
LOG.warn("[{}] The channel was closed because a read timed out",connectionId);
}
ResponseCollector collector = responseCollector.getAndSet(null);
if (collector != null) {
collector.completeExceptionally(cause);
} else {
// this exception can't get back to the client via a future,// use the connection exception handler if possible
if (exceptionHandler.isPresent()) {
exceptionHandler.get().accept(cause);
} else {
super.exceptionCaught(ctx,cause);
}
}
}
项目:Kvantum
文件:KvantumServerHandler.java
@Override
public void exceptionCaught(final ChannelHandlerContext context,final Throwable cause)
{
if ( cause instanceof ReadTimeoutException )
{
if ( CoreConfig.debug )
{
Logger.debug( "Connection for {} timed out",workerContext.getSocketContext().getIP() );
}
} else
{
Logger.error( "Encountered error..." );
cause.printStackTrace();
}
context.close();
}
项目:nedis
文件:RedisDuplexHandler.java
@Override
public void run() {
if (entryQ.isEmpty() || timeoutNs <= 0) {
timeoutTask = null;
return;
}
boolean refillTxnMarker = false;
if (entryQ.peekFirst() == TXN_MARKER) {
entryQ.removeFirst();
refillTxnMarker = true;
}
if (entryQ.isEmpty()) {
entryQ.addFirst(TXN_MARKER);
timeoutTask = null;
return;
}
long nextDelayNs = timeoutNs - (System.nanoTime() - entryQ.peek().nanoTime);
if (nextDelayNs <= 0) {
exceptionCaught(ctx,ReadTimeoutException.INSTANCE);
} else {
timeoutTask = ctx.executor().schedule(this,nextDelayNs,TimeUnit.NANOSECONDS);
if (refillTxnMarker) {
entryQ.addFirst(TXN_MARKER);
}
}
}
项目:nedis
文件:TestNedis.java
@Test
public void testTimeout() throws InterruptedException {
pool = NedisClientPoolBuilder.create()
.remoteAddress(new InetSocketAddress("127.0.0.1",PORT)).database(1).build();
NedisClient client = pool.acquire().sync().getNow();
Thread.sleep(1000);
assertEquals(1,pool.numPooledConns());
assertEquals(1,pool.numConns());
assertEquals(0L,client.setTimeout(100).sync().getNow().longValue());
Future<?> future = client.blpop(1,toBytes("foo")).await();
assertFalse(future.isSuccess());
assertTrue(future.cause() instanceof ReadTimeoutException);
Thread.sleep(1000);
assertEquals(0,pool.numPooledConns());
assertEquals(0,pool.numConns());
}
项目:Pulse
文件:PCSession.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) {
String message;
if (!(cause instanceof ConnectTimeoutException) && (!(cause instanceof ConnectException) || !cause.getMessage()
.contains("connection timed out"))) {
if (cause instanceof ReadTimeoutException) {
message = "Read timed out.";
} else if (cause instanceof WriteTimeoutException) {
message = "Write timed out.";
} else {
message = "Internal network exception.";
}
} else {
message = "Connection timed out.";
}
this.disconnect(message,cause);
}
项目:ProtocolSupport
文件:SimpleReadTimeoutHandler.java
private void initialize(final ChannelHandlerContext ctx) {
this.lastReadTime = System.currentTimeMillis();
this.timeoutTask = ctx.executor().schedule(new Runnable() {
@Override
public void run() {
if (ctx.channel().isOpen()) {
long untilTimeout = timeoutTime - (System.currentTimeMillis() - lastReadTime);
if (untilTimeout <= 0) {
ctx.fireExceptionCaught(ReadTimeoutException.INSTANCE);
} else {
ctx.executor().schedule(this,untilTimeout,TimeUnit.MILLISECONDS);
}
}
}
},this.timeoutTime,TimeUnit.MILLISECONDS);
}
项目:ovsdb
文件:ExceptionHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (ctx.channel().isActive()) {
LOG.error("Exception occurred while processing connection pipeline",cause);
if ((cause instanceof InvalidEncodingException)
|| (cause instanceof TooLongFrameException || (cause instanceof DecoderException))) {
LOG.info("Disconnecting channel to ovsdb {}",ctx.channel());
ctx.channel().disconnect();
return;
}
/* In cases where a connection is quickly established and the closed
Catch the IOException and close the channel. Similarly if the peer is
powered off,Catch the read time out exception and close the channel
*/
if ((cause instanceof IOException) || (cause instanceof ReadTimeoutException)) {
LOG.info("Closing channel to ovsdb {}",ctx.channel());
ctx.channel().close();
return;
}
LOG.error("Exception was not handled by the exception handler,re-throwing it for next handler");
ctx.fireExceptionCaught(cause);
}
}
项目:onos
文件:OFChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) {
if (cause instanceof ReadTimeoutException) {
log.error("Connection closed because of ReadTimeoutException {}",cause.getMessage());
} else if (cause instanceof ClosedChannelException) {
log.error("ClosedChannelException occurred");
return;
} else if (cause instanceof RejectedExecutionException) {
log.error("Could not process message: queue full");
} else if (cause instanceof IOException) {
log.error("IOException occurred");
} else {
log.error("Error while processing message from switch {}",cause.getMessage());
}
channel.close();
}
项目:JLilyPad
文件:ProxyOutboundHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext context,Throwable cause) throws Exception {
Channel channel = context.channel();
if(cause instanceof IOException && cause.getMessage().equals("Connection reset by peer")) {
// ignore
} else if(cause instanceof ReadTimeoutException) {
// ignore
} else if(cause instanceof DecoderException) {
// ignore
} else {
cause.printStackTrace();
}
if(channel.isOpen()) {
channel.close();
}
}
项目:JLilyPad
文件:ProxyInboundHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext context,Throwable cause) throws Exception {
Channel channel = context.channel();
if(cause instanceof IOException && cause.getMessage().equals("Connection reset by peer")) {
// ignore
} else if(cause instanceof ReadTimeoutException) {
// ignore
} else if(cause instanceof DecoderException) {
// ignore
} else {
cause.printStackTrace();
}
if(channel.isOpen()) {
channel.close();
}
}
项目:TakinRPC
文件:ReadTimeoutHandler.java
/**
* Is called when a read timeout was detected.
*/
protected void readTimedOut(ChannelHandlerContext ctx) throws Exception {
if (!closed) {
ctx.fireExceptionCaught(ReadTimeoutException.INSTANCE);
ctx.close();
closed = true;
}
}
项目:talchain
文件:HandshakeHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (channel.isDiscoveryMode()) {
loggerNet.trace("Handshake failed: " + cause);
} else {
if (cause instanceof IOException || cause instanceof ReadTimeoutException) {
loggerNet.debug("Handshake failed: " + ctx.channel().remoteAddress() + ": " + cause);
} else {
loggerNet.warn("Handshake failed: ",cause);
}
}
ctx.close();
}
项目:mqttserver
文件:HttpRequestHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause)
throws Exception {
if (cause instanceof ReadTimeoutException) {
HttpTransport transport = getTransport(ctx);
if (transport != null) {
transport.handleTimeout(ctx);
}
} else {
cause.printStackTrace();
ctx.close();
}
}
项目:iothub
文件:MqttTransportHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) {
log.error("[{}] Unexpected Exception: {}",sessionId,cause);
try {
if (cause.getCause() instanceof ReadTimeoutException) {
ctx.write(PINGRESP).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
} else {
ctx.close();
}
} catch (Throwable t) {
t.printStackTrace();
ctx.close();
}
}
项目:netty-socks
文件:RWTimeoutExceptionHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (cause instanceof ReadTimeoutException) {
handleReadTimeout(ctx);
} else if (cause instanceof WriteTimeoutException) {
handleWriteTimeout(ctx);
} else {
super.exceptionCaught(ctx,cause);
}
}
项目:nearenough
文件:NettyClient.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
ctx.close();
if (cause instanceof ReadTimeoutException) {
System.out.println("No reply received from " + addr);
} else {
System.out.println("Unexpected exception: " + cause.getMessage());
throw new RuntimeException(cause);
}
}
项目:AppCoins-ethereumj
文件:HandshakeHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause);
}
}
ctx.close();
}
项目:fresco_floodlight
文件:AbstractRPCChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (cause instanceof ReadTimeoutException) {
// read timeout
logger.error("[{}->{}] Disconnecting RPC node due to read timeout",getLocalNodeIdString(),getRemoteNodeIdString());
ctx.channel().close();
} else if (cause instanceof HandshakeTimeoutException) {
// read timeout
logger.error("[{}->{}] Disconnecting RPC node due to " +
"handshake timeout",getRemoteNodeIdString());
ctx.channel().close();
} else if (cause instanceof ConnectException ||
cause instanceof IOException) {
logger.debug("[{}->{}] {}: {}",new Object[] {getLocalNodeIdString(),getRemoteNodeIdString(),cause.getClass().getName(),cause.getMessage()});
} else {
logger.error("[{}->{}] An error occurred on RPC channel",new Object[]{getLocalNodeIdString(),cause});
ctx.channel().close();
}
}
项目:iotplatform
文件:MqttTransportHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause);
try {
if (cause.getCause() instanceof ReadTimeoutException) {
ctx.write(PINGRESP).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
} else {
ctx.close();
}
} catch (Throwable t) {
t.printStackTrace();
ctx.close();
}
}
项目:SDN-Multicast
文件:AbstractRPCChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause});
ctx.channel().close();
}
}
项目:arscheduler
文件:AbstractRPCChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause});
ctx.channel().close();
}
}
项目:floodlight1.2-delay
文件:AbstractRPCChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause});
ctx.channel().close();
}
}
项目:nesty
文件:AsyncRequestHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (cause instanceof ReadTimeoutException) {
// httpcode 504
if (context.channel().isOpen())
sendResponse(httpContext,HttpResponseBuilder.create(httpContext,HttpResponseStatus.GATEWAY_TIMEOUT));
}
}
项目:java-restify
文件:NettyHttpClientRequestTest.java
@Test
public void shouldThrowExceptionOnTimeout() {
mockServerClient
.when(request()
.withMethod("GET")
.withPath("/json"))
.respond(response()
.withDelay(TimeUnit.MILLISECONDS,3000));
expectedException.expect(isA(RestifyHttpException.class));
expectedException.expectCause(deeply(ReadTimeoutException.class));
myApi.json();
}
项目:floodlight-hardware
文件:AbstractRPCChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause});
ctx.channel().close();
}
}
项目:Nomad
文件:NomadLobby.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if (cause instanceof ReadTimeoutException) {
logger.debug("Connection timed out.");
onChannelInactive(ctx);
} else {
logger.debug("Exception caught.",cause);
}
}
项目:ACAMPController
文件:AbstractRPCChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause});
ctx.channel().close();
}
}
项目:SI
文件:HttpServerInitializer.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
if(cause instanceof ReadTimeoutException) {
System.out.println("## Read Timeout. ## [Message : " + cause.getMessage() + "]");
} else {
super.exceptionCaught(ctx,cause);
}
}
项目:Camel
文件:NettyRequestTimeoutTest.java
@Test
public void testRequestTimeout() throws Exception {
try {
template.requestBody("netty4:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=1000","Hello Camel",String.class);
fail("Should have thrown exception");
} catch (CamelExecutionException e) {
ReadTimeoutException cause = assertIsInstanceOf(ReadTimeoutException.class,e.getCause());
assertNotNull(cause);
}
}
项目:Camel
文件:NettyRequestTimeoutTest.java
@Test
public void testRequestTimeoutViaHeader() throws Exception {
try {
template.requestBodyAndHeader("netty4:tcp://localhost:{{port}}?textline=true&sync=true",NettyConstants.NETTY_REQUEST_TIMEOUT,1000,e.getCause());
assertNotNull(cause);
}
}
项目:Camel
文件:NettyRequestTimeoutTest.java
@Test
public void testRequestTimeoutAndOk() throws Exception {
try {
template.requestBody("netty4:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=1000",e.getCause());
assertNotNull(cause);
}
// now we try again but this time the is no delay on server and thus faster
String out = template.requestBody("netty4:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=1000","Hello World",String.class);
assertEquals("Bye World",out);
}
项目:Camel
文件:NettyHttpRequestTimeoutTest.java
@Test
public void testRequestTimeout() throws Exception {
try {
template.requestBody("netty4-http:http://localhost:{{port}}/timeout?requestTimeout=1000",e.getCause());
assertNotNull(cause);
}
}
项目:tajo
文件:RemoteFetcher.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause)
throws Exception {
if (cause instanceof ReadTimeoutException) {
LOG.warn(cause.getMessage(),cause);
} else {
LOG.error("Fetch failed :",cause);
}
// this fetching will be retry
IOUtils.cleanup(LOG,fc,raf);
endFetch(FetcherState.FETCH_FAILED);
ctx.close();
}
项目:tajo
文件:LocalFetcher.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,cause);
}
// this fetching will be retry
finishTime = System.currentTimeMillis();
state = TajoProtos.FetcherState.FETCH_FAILED;
ctx.close();
}
项目:spring-boot-admin
文件:InstanceWebClientTest.java
@Test
public void should_error_on_timeout() {
InstanceWebClient fastTimeoutClient = new InstanceWebClient(headersProvider,Duration.ofMillis(10),Duration.ofMillis(10));
wireMock.stubFor(get("/foo").willReturn(ok().withFixedDelay(100)));
Mono<ClientResponse> exchange = fastTimeoutClient.instance(Mono.empty())
.get()
.uri(wireMock.url("/foo"))
.exchange();
StepVerifier.create(exchange).verifyError(ReadTimeoutException.class);
}
项目:laputa
文件:LaputaServerHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) {
ctx.close();
if (cause instanceof IOException ||
cause instanceof ReadTimeoutException) {
return;
}
LOGGER.error(cause.getMessage(),cause);
}
项目:Statik-Report
文件:EndOfTheLine.java
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,final Throwable cause) throws Exception {
// The client idled for too long,so we'll just close their channel and move on.
// OR The client disconnected early
// TODO: Fix ignoring all IOExceptions (some may be legitimate)
if (cause instanceof ReadTimeoutException || cause instanceof IOException) {
ctx.close();
return;
}
this.rs.getLogger().severe("An uncaught exception occurred somewhere in the pipeline:");
this.rs.getLogger().log(Level.SEVERE,cause.getMessage(),cause);
cause.printStackTrace();
}