Skip to content

no doc related to hearbeat use case when connection is for push only events #492

Closed

Description

@jjuraszek

right now according to doc you have to read from connection to fire SetPongHandler event. But if the websocket is used for push only it won't be fired. Solution is to use:

go ws.NextReader()

But the doc is not very straight forward about that. In my opinion there should be description of how to setup heartbeat in case of push only usage. Let me know if you need help with that.

Activity

  1. jjuraszek commented on Mar 19, 2019

    @jjuraszek
    Author

    The read operation is blocking so c.Close() might not ever happen for unresponsive client. Therefore I think it's not right way to implement heartbeat procedure. I think it should be explicitly described procedure of using:

    • websocket.Conn.SetPongHandler for registration of last PONG time from client
    • websocket.Conn.NextReader() for reassurance that PONG is even obtained
    • websocket.Conn.WriteMessage(websocket.PingMessage, ...) for sending PING and checking if there is no socket issue

    I'm not saying that there is no documentation. I'm just saying that this common use case is not covered as whole neither by examples nor by documentation. All breadcrumbs are separated ;)

    It takes me at least 2h to figure out how to do it right. So I can create example to save time of others working on similar case. Does it sound reasonable?

  2. elithrar commented on Mar 19, 2020

    @elithrar
    Contributor

    Closing this one out for now.

  3. ozgurakcali commented on Nov 4, 2020

    @ozgurakcali

    A dummy reader should not be necessary to be able to respond to ping messages IMO. Even if it is documented, it doesn't feel natural.

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

      ⌂ 换网址