Skip to content

Clarification of reconnect semantics #500

Closed
@pigulla

Description

@pigulla

I'm developing an application where clients can subscribe to a variety of events fired by the server. These subscriptions are highly parameterized and can thus not be modeled adequately with Socket.IO's channel feature (e.g., the client can subscribe to all events of type X but filter them by field A and only receive fields B and C). The server keeps track of all subscriptions and dispatches incoming events accordingly.

I've looked through the source code but am still having trouble figuring out what exactly happens when a reconnect occurs and how it should be handled. For instance:

  • Should I require the client to authenticate itself again (in our case by sending a token)? I know this is primarily an application issue but it may be relevant if it is possible for a client to trick the server into treating a regular connection attempt as a reconnect. I don't know enough about the Socket.IO protocol to answer this.
  • What happens when the server is restarted and that causes the client to reconnect (in which case the client needs to send all subscribe messages again)? How can I distinguish this from a "client-side" reconnect?
  • How can I simulate a disconnect (i.e., force a reconnect)? I need to do this programmatically in order to write unit tests.
  • If the server closes the connection (e.g. because maintenance requires a restart) and I need to reconnect, how do I do that? Currently I call connection.socket.connect() but I'm not sure that it is intended to be used that way.

Any infos on theses issues are highly appreciated.

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