Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Close connections gracefully. #15

Open

Description

@Lukasa

We should send GoAway frames when we close a connection.

Activity

  1. added this to the 0.0.2 milestone on Feb 16, 2014
  2. removed this from the 0.0.2 milestone on Feb 18, 2015
  3. jdecuyper commented on May 13, 2015

    @jdecuyper
    Contributor

    Hi @Lukasa!

    Spec says: Endpoints SHOULD send a GOAWAY frame when ending a connection, providing that circumstances permit it.

    So when shutting down gracefully we need to call close on all streams and then send a final GoAway frame on the connection control stream, something like:

    # Close all streams
    for stream in list(self.streams.values()):
       print("Closing stream with id %d" % stream.stream_id)
       stream.close()
    
    # Send GoAway frame to the server
       self._send_cb(GoAwayFrame(0), True)
    

    I think we should also close the stream for connection control with id 0, but I'm not sure yet where it is.

    On a related matter, the spec also says An endpoint that receives an unexpected stream identifier MUST respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR. I don't think we are validating if the stream identifier actually exists or not on the client side. Code looks as follow right now:

    self.streams[frame.stream_id].receive_frame(frame)
    

    I guess we should validate first if this stream_id exists inside the streams collection, right?

  4. Lukasa commented on May 13, 2015

    @Lukasa
    MemberAuthor

    I think we should also close the stream for connection control with id 0, but I'm not sure yet where it is.

    Stream zero always exists, and there is no need to explicitly close it.

    I guess we should validate first if this stream_id exists inside the streams collection, right?

    A try...except block would be better style, but yes. =)

    So when shutting down gracefully we need to call close on all streams and then send a final GoAway frame on the connection control stream

    Sounds like a good idea to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions