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;
}
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));
}
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;
}
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);
}
}
Aggregations