Can't get Peer server working with Express
See original GitHub issueHello,
I’ve got a simple code that doesn’t work :
var express = require('express');
var app = express();
var ExpressPeerServer = require('peer').ExpressPeerServer;
app.get('/', function(req, res, next) {
console.log("get /")
res.send('Hello world!');
});
var server = app.listen(9000);
var options = {
debug: true,
allow_discovery: true
}
app.use('/api', ExpressPeerServer(server, options));
server.on('connection', function(id) {
console.log(id)
console.log(server._clients)
});
server.on('disconnect', function(id) {
console.log(id + "deconnected")
});
The code is from the Readme.
The issue is that I get a wrong id in the server.on(‘connection’, …) callback :
- I want a text ID
- I got a socket object…
From what I have studied, the signal we react to comes from onconnection in net.js. Here is the complete stacktrace of the event call :
main.js:25 (server.on(‘connection’, …) EventEmitter.emit (events.js:117) onconnection (net.js:1188)
Is there a way to fix this behaviour ?
Thanks
Issue Analytics
- State:
- Created 8 years ago
- Comments:9
Top Results From Across the Web
Peer cli works but ExpressPeerServer doesnt - Stack Overflow
I am trying to get an express peerJs server up and running locally over HTTPS. Now if i start the peerJS server via...
Read more >Lost connection to server. PeerServer with express app.
Small update, i get back to establishing peerjs server on express app. This time problem solved. Extremely simple, just by updating my node,...
Read more >apollo-server-express - npm
Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks. Read the docs. Read the ...
Read more >Taming WebRTC with PeerJS: Making a Simple P2P Web Game
A string that the peer can choose itself, or have a server generate one. ... Now that we have a source of confidence...
Read more >Peer NPM
If you have your own server, you can attach PeerServer. ... If the server doesn't receive any data from client (includes pong messages),...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I fix my problem after moving integrating peer part up.
FYI: error happen with below code
I recommand to improve the docs for the project. I will see if I can help.