Search in sources :

Example 1 with StreamException

use of com.webpieces.http2.api.dto.error.StreamException 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 2 with StreamException

use of com.webpieces.http2.api.dto.error.StreamException in project webpieces by deanhiller.

the class Level6LocalFlowControl method fireDataToClient.

public XFuture<Void> fireDataToClient(Stream stream, StreamMsg payload) {
    if (!(payload instanceof DataFrame))
        return notifyListener.sendPieceToApp(stream, payload);
    DataFrame f = (DataFrame) payload;
    long frameLength = f.getTransmitFrameLength();
    if (frameLength > connectionLocalWindowSize) {
        throw new ConnectionException(CancelReasonCode.FLOW_CONTROL_ERROR, logId, f.getStreamId(), "connectionLocalWindowSize too small=" + connectionLocalWindowSize + " frame len=" + frameLength + " for frame=" + f);
    } else if (frameLength > stream.getLocalWindowSize()) {
        throw new StreamException(CancelReasonCode.FLOW_CONTROL_ERROR, logId, f.getStreamId(), "connectionLocalWindowSize too small=" + connectionLocalWindowSize + " frame len=" + frameLength + " for frame=" + f);
    }
    totalSent += frameLength;
    connectionLocalWindowSize -= frameLength;
    stream.incrementLocalWindow(-frameLength);
    log.info("received framelen=" + frameLength + " newConnectionWindowSize=" + connectionLocalWindowSize + " streamSize=" + stream.getLocalWindowSize() + " totalSent=" + totalSent);
    return notifyListener.sendPieceToApp(stream, payload).thenApply(c -> updateFlowControl(frameLength, stream));
}
Also used : DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException) StreamException(com.webpieces.http2.api.dto.error.StreamException)

Example 3 with StreamException

use of com.webpieces.http2.api.dto.error.StreamException in project webpieces by deanhiller.

the class Level5AStates method translateException.

private XFuture<Void> translateException(Stream stream, Throwable t) {
    XFuture<Void> fut = new XFuture<>();
    if (t instanceof NoTransitionConnectionError)
        fut.completeExceptionally(new ConnectionException(CancelReasonCode.BAD_FRAME_RECEIVED_FOR_THIS_STATE, logId, stream.getStreamId(), t.getMessage(), t));
    else if (t instanceof NoTransitionStreamError)
        fut.completeExceptionally(new StreamException(CancelReasonCode.CLOSED_STREAM, logId, stream.getStreamId(), t.getMessage(), t));
    else
        fut.completeExceptionally(t);
    return fut;
}
Also used : NoTransitionStreamError(com.webpieces.http2engine.impl.shared.data.NoTransitionStreamError) XFuture(org.webpieces.util.futures.XFuture) NoTransitionConnectionError(com.webpieces.http2engine.impl.shared.data.NoTransitionConnectionError) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException) StreamException(com.webpieces.http2.api.dto.error.StreamException)

Example 4 with StreamException

use of com.webpieces.http2.api.dto.error.StreamException in project webpieces by deanhiller.

the class Level5BResets method sendRstToServerAndApp.

public XFuture<Void> sendRstToServerAndApp(StreamException e) {
    RstStreamFrame frame = new RstStreamFrame();
    frame.setKnownErrorCode(e.getReason().getErrorCode());
    frame.setStreamId(e.getStreamId());
    boolean streamExist = streamState.isStreamExist(frame);
    if (streamExist) {
        Stream stream = streamState.getStream(frame, true);
        return fireRstToSocket(stream, frame).thenCompose(v -> {
            XFuture<Void> future = fireRstToClient(stream, frame);
            return future;
        });
    } else {
        // no stream means idle or closed...
        return remoteFlowControl.fireResetToSocket(frame);
    }
}
Also used : RstStreamFrame(com.webpieces.http2.api.dto.lowlevel.RstStreamFrame) ShutdownStream(com.webpieces.http2engine.api.error.ShutdownStream) Stream(com.webpieces.http2engine.impl.shared.data.Stream)

Aggregations

ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)3 StreamException (com.webpieces.http2.api.dto.error.StreamException)3 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)2 RstStreamFrame (com.webpieces.http2.api.dto.lowlevel.RstStreamFrame)2 XFuture (org.webpieces.util.futures.XFuture)2 HpackParser (com.webpieces.hpack.api.HpackParser)1 UnmarshalState (com.webpieces.hpack.api.UnmarshalState)1 CancelReasonCode (com.webpieces.http2.api.dto.error.CancelReasonCode)1 Http2Trailers (com.webpieces.http2.api.dto.highlevel.Http2Trailers)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 SettingsFrame (com.webpieces.http2.api.dto.lowlevel.SettingsFrame)1 UnknownFrame (com.webpieces.http2.api.dto.lowlevel.UnknownFrame)1 WindowUpdateFrame (com.webpieces.http2.api.dto.lowlevel.WindowUpdateFrame)1 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)1 Http2Config (com.webpieces.http2engine.api.client.Http2Config)1 ConnectionClosedException (com.webpieces.http2engine.api.error.ConnectionClosedException)1 ConnectionFailure (com.webpieces.http2engine.api.error.ConnectionFailure)1 ReceivedGoAway (com.webpieces.http2engine.api.error.ReceivedGoAway)1