question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Object #<Namespace> has no method 'clients'

See original GitHub issue

The ability to get all clients in a room with the following calls described in the wiki has been broken:

  • io.sockets.clients('room')
  • io.of('namespace').clients('room')

If you run the following test, it will fail when run against the latest git master with the reason “Uncaught TypeError: Object #<Namespace> has no method ‘clients’”:

it('should return the sockets in a room', function(done){
var srv = http();
var sio = io(srv);
var roomId = 'socketsInRoom';

sio.on('connect', function (socket) {
  socket.join(roomId, function () {
    expect(sio.sockets.clients(roomId)).to.contain(socket);
    done();
  });
});

srv.listen(function(){
  client(srv);
});
});

Was this functionality removed intentionally, or just accidentally because there was no spec testing for the clients function?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
ohEmilycommented, Jun 16, 2014

I’m having trouble making this work when limited to a particular namespace. Rather than just using io.sockets, I am limiting the relevant connections to a namespace. Before switching to Socket.IO v1 and above, the code used to read:

    var chat = io.of('/chat').on('connection', function(clntSocket)
    {         
      // each client is put into a chat room restricted to max 2 clients
      clntSocket.on('joinRoom', function(room_id)
      {
        var clients_in_room = chat.clients(room_id).length;   
                // ... etc

Now, I’m trying to change that last line as per the instructions in this thread. Why doesn’t this work?

var clients_in_room = chat.adapter.rooms[room_id].length;

In the past, I could just substitute io.sockets for the variable name I created for that namespace, chat (in this case).

Any ideas?

0reactions
wamoyocommented, Jan 5, 2015

I had this issue too, Thanks Lucas! This blog post should be updated: http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/ Will let them know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Joining same room more then once and clients in a room #1544
clients ('room') I get Object #<Namespace> has no method 'clients' . So I got two questions: what happens if client tries to join...
Read more >
AttributeError: 'Namespace' object has no attribute
You're parsing command line arguments into args , which is a Namespace with attributes set to the parsed arguments.
Read more >
Migrating from 2.x to 3.0 - Socket.IO
The documentation can be found here. Uncaught TypeError: packet.data is undefined. It seems that you are using a v3 client to connect to...
Read more >
ASP.NET Core SignalR JavaScript client - Microsoft Learn
The ASP.NET Core SignalR JavaScript client library enables developers to call server-side SignalR hub code. Install the SignalR client package.
Read more >
Google Visualization API Reference | Charts
This page lists the objects exposed by the Google Visualization API, and the standard methods exposed by all visualizations. Note: The Google Visualization...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found