Skip to content

io.of('/').connected[socketId] does not always return socket object #283

@joanmooreban

Description

@joanmooreban

Before implementing socket.io-redis I used the following to get the socket object:

var socket = io.sockets.connected[socketId];

Now that I've implemented socket.io-redis I guess the command to replace it is:

var socket = io.of('/).connected[socketId];

However, it returns undefined in many, many cases where the socket actually exists.

I need to know how to get a socket's object by its id but without using any callback function since in my initial implementation I used as a return value as showed above and it is being currently used in many parts of the app.

UPDATE Jun 20th

I've also unsucessfully tried with io.of('/').adapter.nsp.connected[socket_id];. It replies with the right socket object for just some cores, not for all of them, returning undefined most of the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions