#StackBounty: #peerjs Getting Started With PeerJS

Bounty: 50

I am trying the simplest example I can, pulled directly from their website. Here is my entire html file, with code taken exactly from https://peerjs.com/index.html:

https://unpkg.com/peerjs@1.3.1/dist/peerjs.min.js
<script>
    var peer = new Peer();
    var conn = peer.connect('another-peers-id');
    // on open will be launch when you successfully connect to PeerServer
    conn.on('open', function(){
    // here you have conn.id
        conn.send('hi!');
    });
</script>

In Chrome and Edge I get this in the console:

peerjs.min.js:64 GET https://0.peerjs.com/peerjs/id?ts=15956160926060.016464029424720694 net::ERR_CONNECTION_REFUSED

In Firefox I get this:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://0.peerjs.com/peerjs/id?ts=15956162489620.8436734374800061. (Reason: CORS request did not succeed).

What am I doing wrong?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.