Search in sources :

Example 1 with ConnectionFailure

use of com.webpieces.http2engine.api.error.ConnectionFailure in project webpieces by deanhiller.

the class Level2ParsingAndRemoteSettings method handleError.

private Void handleError(Object object, Throwable e) {
    if (e == null)
        return null;
    else if (e instanceof ConnectionClosedException) {
        log.error("Normal exception since we are closing and they do not know yet", e);
    } else if (e instanceof StreamException) {
        log.error("shutting the stream down due to error", e);
        syncro.sendRstToServerAndApp((StreamException) e).exceptionally(t -> logExc("stream", t));
    } else if (e instanceof ConnectionException) {
        log.error("shutting the connection down due to error", e);
        ConnectionFailure reset = new ConnectionFailure((ConnectionException) e);
        //send GoAway
        syncro.sendGoAwayToSvrAndResetAllToApp(reset).exceptionally(t -> logExc("connection", t));
    } else {
        log.error("shutting the connection down due to error(MAKE sure your clients try..catch, exceptions)", e);
        ConnectionException exc = new ConnectionException(CancelReasonCode.BUG, logId, 0, e.getMessage(), e);
        ConnectionFailure reset = new ConnectionFailure((ConnectionException) exc);
        //send GoAwa
        syncro.sendGoAwayToSvrAndResetAllToApp(reset).exceptionally(t -> logExc("connection", t));
    }
    return null;
}
Also used : Http2Trailers(com.webpieces.hpack.api.dto.Http2Trailers) UnknownFrame(com.webpieces.http2parser.api.dto.UnknownFrame) ConnectionClosedException(com.webpieces.http2engine.api.ConnectionClosedException) Http2Config(com.webpieces.http2engine.api.client.Http2Config) CompletableFuture(java.util.concurrent.CompletableFuture) CancelReasonCode(com.webpieces.http2parser.api.dto.error.CancelReasonCode) Http2Msg(com.webpieces.http2parser.api.dto.lib.Http2Msg) HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings) SettingsFrame(com.webpieces.http2parser.api.dto.SettingsFrame) HpackParser(com.webpieces.hpack.api.HpackParser) UnmarshalState(com.webpieces.hpack.api.UnmarshalState) DataWrapper(org.webpieces.data.api.DataWrapper) StreamException(com.webpieces.http2parser.api.dto.error.StreamException) Logger(org.webpieces.util.logging.Logger) PriorityFrame(com.webpieces.http2parser.api.dto.PriorityFrame) ConnectionFailure(com.webpieces.http2engine.api.error.ConnectionFailure) PingFrame(com.webpieces.http2parser.api.dto.PingFrame) GoAwayFrame(com.webpieces.http2parser.api.dto.GoAwayFrame) List(java.util.List) ReceivedGoAway(com.webpieces.http2engine.api.error.ReceivedGoAway) RstStreamFrame(com.webpieces.http2parser.api.dto.RstStreamFrame) WindowUpdateFrame(com.webpieces.http2parser.api.dto.WindowUpdateFrame) ConnectionException(com.webpieces.http2parser.api.dto.error.ConnectionException) LoggerFactory(org.webpieces.util.logging.LoggerFactory) DataFrame(com.webpieces.http2parser.api.dto.DataFrame) ConnectionFailure(com.webpieces.http2engine.api.error.ConnectionFailure) ConnectionClosedException(com.webpieces.http2engine.api.ConnectionClosedException) ConnectionException(com.webpieces.http2parser.api.dto.error.ConnectionException) StreamException(com.webpieces.http2parser.api.dto.error.StreamException)

Example 2 with ConnectionFailure

use of com.webpieces.http2engine.api.error.ConnectionFailure in project webpieces by deanhiller.

the class Level2ParsingAndRemoteSettings method handleFinalError.

private Void handleFinalError(Object object, Throwable e) {
    if (e == null)
        return null;
    else if (e instanceof ConnectionException) {
        log.error("shutting the connection down due to error", e);
        ConnectionFailure reset = new ConnectionFailure((ConnectionException) e);
        // send GoAway
        syncro.sendGoAwayToSvrAndResetAllToApp(reset).exceptionally(t -> logExc("connection", t));
    } else if (e instanceof StreamException) {
        log.error("Stream had an error", e);
        streamsToDiscard.add(((StreamException) e).getStreamId());
        syncro.sendRstToServerAndApp((StreamException) e).exceptionally(t -> logExc("stream", t));
    } else {
        log.error("shutting the connection down due to error(MAKE sure your clients try..catch, exceptions)", e);
        ConnectionException exc = new ConnectionException(CancelReasonCode.BUG, logId, 0, e.getMessage(), e);
        ConnectionFailure reset = new ConnectionFailure((ConnectionException) exc);
        // send GoAwa
        syncro.sendGoAwayToSvrAndResetAllToApp(reset).exceptionally(t -> logExc("connection", t));
    }
    return null;
}
Also used : WindowUpdateFrame(com.webpieces.http2.api.dto.lowlevel.WindowUpdateFrame) PriorityFrame(com.webpieces.http2.api.dto.lowlevel.PriorityFrame) RstStreamFrame(com.webpieces.http2.api.dto.lowlevel.RstStreamFrame) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) Http2Config(com.webpieces.http2engine.api.client.Http2Config) LoggerFactory(org.slf4j.LoggerFactory) UnknownFrame(com.webpieces.http2.api.dto.lowlevel.UnknownFrame) ByteAckTracker(org.webpieces.util.acking.ByteAckTracker) HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings) PingFrame(com.webpieces.http2.api.dto.lowlevel.PingFrame) HpackParser(com.webpieces.hpack.api.HpackParser) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException) UnmarshalState(com.webpieces.hpack.api.UnmarshalState) DataWrapper(org.webpieces.data.api.DataWrapper) SettingsFrame(com.webpieces.http2.api.dto.lowlevel.SettingsFrame) ConnectionClosedException(com.webpieces.http2engine.api.error.ConnectionClosedException) Logger(org.slf4j.Logger) GoAwayFrame(com.webpieces.http2.api.dto.lowlevel.GoAwayFrame) ConnectionFailure(com.webpieces.http2engine.api.error.ConnectionFailure) CancelReasonCode(com.webpieces.http2.api.dto.error.CancelReasonCode) List(java.util.List) StreamException(com.webpieces.http2.api.dto.error.StreamException) ReceivedGoAway(com.webpieces.http2engine.api.error.ReceivedGoAway) DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) XFuture(org.webpieces.util.futures.XFuture) Http2Trailers(com.webpieces.http2.api.dto.highlevel.Http2Trailers) ConnectionFailure(com.webpieces.http2engine.api.error.ConnectionFailure) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException) StreamException(com.webpieces.http2.api.dto.error.StreamException)

Example 3 with ConnectionFailure

use of com.webpieces.http2engine.api.error.ConnectionFailure in project webpieces by deanhiller.

the class ResponseListener method failure.

@Override
public void failure(Throwable e) {
    ConnectionCancelled connCancelled = new ConnectionFailure(new ConnectionException(CancelReasonCode.BUG, logId, 0, "Failure from connection", e));
    responseListener.cancel(new ShutdownStream(0, connCancelled));
}
Also used : ShutdownStream(com.webpieces.http2engine.api.error.ShutdownStream) ConnectionFailure(com.webpieces.http2engine.api.error.ConnectionFailure) ConnectionCancelled(com.webpieces.http2engine.api.error.ConnectionCancelled) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException)

Example 4 with ConnectionFailure

use of com.webpieces.http2engine.api.error.ConnectionFailure in project webpieces by deanhiller.

the class Level4PreconditionChecks method createExcepted.

public XFuture<Void> createExcepted(Http2Msg payload, String extra, ConnectionCancelled closedReason) {
    log.info("returning XFuture.exception since this socket is closed('" + extra + "' frame=" + payload + "):" + closedReason.getReasonCode());
    XFuture<Void> future = new XFuture<>();
    ConnectionClosedException exception = new ConnectionClosedException(closedReason, "Connection closed or closing:" + closedReason.getReasonCode());
    if (closedReason instanceof ConnectionFailure) {
        ConnectionFailure fail = (ConnectionFailure) closedReason;
        exception.initCause(fail.getCause());
    }
    future.completeExceptionally(exception);
    return future;
}
Also used : ConnectionFailure(com.webpieces.http2engine.api.error.ConnectionFailure) XFuture(org.webpieces.util.futures.XFuture) ConnectionClosedException(com.webpieces.http2engine.api.error.ConnectionClosedException)

Aggregations

ConnectionFailure (com.webpieces.http2engine.api.error.ConnectionFailure)4 HpackParser (com.webpieces.hpack.api.HpackParser)2 UnmarshalState (com.webpieces.hpack.api.UnmarshalState)2 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)2 Http2Config (com.webpieces.http2engine.api.client.Http2Config)2 ConnectionClosedException (com.webpieces.http2engine.api.error.ConnectionClosedException)2 ReceivedGoAway (com.webpieces.http2engine.api.error.ReceivedGoAway)2 HeaderSettings (com.webpieces.http2engine.impl.shared.data.HeaderSettings)2 List (java.util.List)2 DataWrapper (org.webpieces.data.api.DataWrapper)2 Http2Trailers (com.webpieces.hpack.api.dto.Http2Trailers)1 CancelReasonCode (com.webpieces.http2.api.dto.error.CancelReasonCode)1 StreamException (com.webpieces.http2.api.dto.error.StreamException)1 Http2Trailers (com.webpieces.http2.api.dto.highlevel.Http2Trailers)1 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)1 GoAwayFrame (com.webpieces.http2.api.dto.lowlevel.GoAwayFrame)1 PingFrame (com.webpieces.http2.api.dto.lowlevel.PingFrame)1 PriorityFrame (com.webpieces.http2.api.dto.lowlevel.PriorityFrame)1 RstStreamFrame (com.webpieces.http2.api.dto.lowlevel.RstStreamFrame)1 SettingsFrame (com.webpieces.http2.api.dto.lowlevel.SettingsFrame)1