Skip to content

Tolerate send_open() at Closed state?  #803

Open
@vilicvane

Description

@vilicvane

I am having some issue with tunneling TCP using h2, it aborts the connection after the server (usually speedtest servers) resets the connection and h2 trying to send_open().

Not sure if this should be tolerated by h2 or to be handled by my code. I tried to do an early return with a Closed state and it seems to fix my problem.

    pub fn send_open(&mut self, eos: bool) -> Result<(), UserError> {
        let local = Streaming;

        if matches!(self.inner, Inner::Closed(_)) {
            return Ok(());
        }

pub fn send_open(&mut self, eos: bool) -> Result<(), UserError> {
let local = Streaming;
self.inner = match self.inner {
Idle => {
if eos {
HalfClosedLocal(AwaitingHeaders)
} else {
Open {
local,
remote: AwaitingHeaders,
}
}
}
Open {
local: AwaitingHeaders,
remote,
} => {
if eos {
HalfClosedLocal(remote)
} else {
Open { local, remote }
}
}
HalfClosedRemote(AwaitingHeaders) | ReservedLocal => {
if eos {
Closed(Cause::EndStream)
} else {
HalfClosedRemote(local)
}
}
_ => {
// All other transitions result in a protocol error
return Err(UserError::UnexpectedFrameType);
}
};
Ok(())
}

Any suggestions on a proper workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions