Problem with Peerjs of nodejs for a Peer to Peer Video chat

Greetings to JS and Node.js Gods here

We are working to offer our members a free Peer-to-Peer WebRTC node.js based Video chat.
And we are having problem with the Peerjs part of this code.

To be exact we are following the instructions here for creating this Peer-to-Peer Video chat:

We got it working Ok from connecting to Node.js server and obtaining socket.id to getting our local Video feed as you can see here:
https://www.anoox.com/chat/video_chat_dev.php

However when we add the peerjs part to the client side code, as in here:
https://www.anoox.com/chat/video_chat_dev_wPeer.php

from steps here: https://peerjs.com/

Then we get Error: Uncaught ReferenceError: Peer is not defined

Can you let us know what we need to do to fix this Error?

Notes:
1- Above pages to this Peer-to-Peer Video chat are the development pages, so the CSS stuff is not pretty, and room id is hard coded.
Please ignore that. The real public version will be much better looking. And pages (rooms) will be dynamically created for each member, etc.

2- We already offer our members free node.js based Text chat
so we are pretty solid and experienced when it comes to node.js stuff and live chat related stuff

Thanks

Hey @WorldNews, you have set the defer attribute on the script loading peerjs, which means that it will only get loaded after the document – including your own script – got parsed. So just remove the deferral and it should work.

Hello M3g,

I did as you suggested and removed “defer” from JS files being loaded.
But it is still throwing the same Error!
Which you can see in the test dev page above, that is here:
https://www.anoox.com/chat/video_chat_dev_wPeer.php

Thanks

You have a typo there – the error message is:

Uncaught ReferenceError: mypeer is not defined

… but it should be myPeer with camel case (and previously it was just Peer that was not defined).

Hello m3g,

I changed that Upper case mis-mtach.
But it throws the same Error.
To be exact I even tried it with both Upper case & Lower case as here:

var myPeer = new peer();
myPeer.on(‘open’, function(id) {
console.log('My peer ID is: ’ + id);
});

var myPeer = new Peer();
myPeer.on(‘open’, function(id) {
console.log('My peer ID is: ’ + id);
});

And it throws the Error:

Uncaught ReferenceError: peer is not defined

Thanks for your Help

Cant believe we have lost days over something that should be so straight forward :frowning:

M3,

Hey, I finally got the problem resolved.
Yahooo after 3 days :slight_smile:
FYI, got it working after moving the JS Code to our server!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.