Skip to content

Don't process socket.connect() if already reconnecting #576

Closed
@KushtrimPacaj

Description

@KushtrimPacaj

Don't process any call socket.connect() again after the first time. It screws up badly ( and not transparently ) its own internal reconnecting process, and can lead to socket not being connected and not even trying to connect.

Let's assume the socket is already in reconnecting 'mode', and has tried a few times ( backoff.getAttempts() > 0 ).
Now if you call socket.connect(), it internally invokes manager.open(null), which only tries once, and after failing it does cleanup by destroying all subs, which in turn gets the reconnecting timer canceled.

After failing, maybeReconnectOnOpen() get's called, but doesn't tigger reconnect due to backoff.getAttempts() > 0.

So we get into a state where we aren't trying to reconnect ( we canceled the timer ), and don't trigger reconnect again.

¯\_(ツ)_/¯

I fixed my code by not ever calling socket.connect() again after first time ( unless I call destroy), but this is an easy mistake to make which leads to weird and un-documented behaviour.

I'll add a PR if it the project owners will consider it ?

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