DEV Community

Discussion on: Let’s Build a Video Chat App with JavaScript and WebRTC

Collapse
 
xgubianas profile image
xgubianas

In my maltop, I reach the "enter room name" and then I get a blue background screen with nothing...
But if I'll do the same in my mobile, in the console node.js I get this error:

/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/index.js:47
var numClients = clientsInRoom ? Object.keys(clientsInRoom.sockets).length : 0;
^

TypeError: Cannot convert undefined or null to object
at Function.keys ()
at Socket. (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/index.js:47:44)
at Socket.emit (events.js:315:20)
at Socket.onevent (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/socket.io/lib/socket.js:327:8)
at Socket.onpacket (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/socket.io/lib/socket.js:287:12)
at Client.ondecoded (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/socket.io/lib/client.js:185:14)
at Decoder.Emitter.emit (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/component-emitter/index.js:134:20)
at Decoder.add (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/socket.io-parser/index.js:247:12)
at Client.ondata (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/socket.io/lib/client.js:170:16)
at Socket.emit (events.js:315:20)

Any idea?

Thanks !!!

Collapse
 
robertloeberdevelopment profile image
Robert Loeber

I found it. I had the same error.
line 47, index.js:
var numClients = clientsInRoom ? Object.keys(clientsInRoom.sockets).length : 0;
change it to:
var numClients = clientsInRoom ? Object.keys(clientsInRoom).length : 0;

the first time there is no room, and the object is made bij 'join' with teh name of the room. When the second user joins, the room object is made but:
'sockets' appears not to be a property,and gives 'undefined'. so leave it out.
It probably has to to with different versions of socket.io. It took a couple of hours to find this out.

Collapse
 
shivamag00 profile image
Shivam Agarwal

@xgubianas , This is Shivam. @nilmadhabmondal informed me that you wanted to integrate WEBRTC with your veterinary project. Please DM me on Dev.to