peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.48k stars 1.43k forks source link

Firefox can't establish a connection to the server at wss://localhost/peerjs?key=peerjs&id=ZNfSEBbys&token=cklszm3tnu. #797

Closed CuAnnan closed 3 years ago

CuAnnan commented 3 years ago
const createError = require('http-errors');
const express = require('express');
const session = require('express-session');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const debug = require('debug')('nodesaken:server');
const MongoDBStore = require('connect-mongodb-session')(session);
const mongoose = require('mongoose');
const app = express();
const conf = require('./conf.js');
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const {PeerServer, ExpressPeerServer} = require('peer');

app.use('/peerjs', ExpressPeerServer(app,{debug:true}));

The rest of the app.js stuff is doing various things like bootstrapping mongoose, setting routers, handling auth.

The front end code looks like

<script src="/js/peerjs.min.js"></script>
<script type="text/javascript">
    (function($) {
        $(function() {
            console.log("Onload event fired");
            const peer = new Peer(
                    '<%- peerId %>',
                    {
                        host:'localhost',
                        path:'/',
                        port:443
                    }
            );
            peer.on('open', function (id) {
                console.log("Peer connection up and running");
            });
        });
    })(window.jQuery);
</script>

https://localhost/peerjs returns the expected JSON

Any attempt to hoist a peerjs connection fails.

CuAnnan commented 3 years ago

https://localhost/peerjs/id also results in a 404 and the node output lists GET /peerjs/id 404 1.164 ms - 1741

Which would imply that app.use('/peerjs') is not being respected.

CuAnnan commented 3 years ago

Setting Debug to 3 on the client side returne

PeerJS:  Socket closed. 
close { target: WebSocket, isTrusted: true, wasClean: false, code: 1006, reason: "", srcElement: WebSocket, currentTarget: WebSocket, eventPhase: 2, bubbles: false, cancelable: false, … }
logger.ts:57:12
ERROR PeerJS:  Error: Lost connection to server. logger.ts:61:12
PeerJS:  Disconnect peer with ID:ZNfSEBbys logger.ts:57:12
CuAnnan commented 3 years ago

Wrong depot. WIll repost to peer-server now