Lost connection to server. PeerServer with express app.

1,524 views
Skip to first unread message

Max Yari

unread,
Dec 17, 2014, 10:12:12 AM12/17/14
to pee...@googlegroups.com
Greetings, gentlemen.

In last few days I had some problems with connection to PeerJS cloudserver, to make some of my tests, therefore i decided, that it's finally a time to deploy PeerServer on my node.js+express+socket.io server. But after a while I stuck with a problem.
So, I got 'Lost Connection to Server' error message almost immedietly after id is given to user. No connection to PeerServer message being fired, but disconnect message is fired, when i reload a page, therefore cleaning a peer, after error message.

Related code parts on my server side: 

//////////////////////////////////////////////////////////////
var express = require('express');
var app = express()
  , http = require('http')
  , server = http.createServer(app)
  , io = require('socket.io').listen(server)
  , ExpressPeerServer = require('peer').ExpressPeerServer
  , options = {
      debug: true
  }
  , expresspeerserver = ExpressPeerServer(server, options)

app.use(express.static(__dirname + '/public'));
app.use('/peerjs', expresspeerserver);

expresspeerserver.on('connection', function (id) {
    console.log('HEY HOW ' + id + ' seeking for peers');
});
 
expresspeerserver.on('disconnect', function (id) {
    console.log('HEY HOW ' + id + ' disconnected');
});

server.listen(4242);
//////////////////////////////////////////////////////

And on client side:

//////////////////////////////////////////////////////
var peer = new Peer({host: location.host.split(':')[0], port: location.host.split(':')[1], path: '/peerjs'});

//////////////////////////////////////////////////////

Moreover with this error, I got also an error message from peer.min.js (which is on my server also) in js console in google chrome:
"WebSocket connection to 'ws://localhost:4242/peerjs/peerjs?key=peerjs&id=p6p7i8fuxrctbj4i&token=brjkrhwc5uhm2t9' failed: Connection closed before receiving a handshake response"

Hope for your response.

P.S.: PeerJs is one hell of an awesome thing, thank you, devs, for it.

Max Yari

unread,
Dec 18, 2014, 11:49:17 AM12/18/14
to pee...@googlegroups.com
And whole day today I have 'could not get id from the server' error with cloudserver, yet sometime it gets id, but on firefox shortly after than gives Lost connection error

Max Yari

unread,
Dec 24, 2014, 4:36:30 AM12/24/14
to pee...@googlegroups.com
 Merry X-Mass
Yet waiting for some help...

Michelle Bu

unread,
Dec 24, 2014, 3:03:51 PM12/24/14
to Max Yari, peerjs
Hello!

Cloud server should definitely be up right now--are you still
experiencing intermittent issues?
Michelle

Max Yari

unread,
Dec 25, 2014, 9:16:18 AM12/25/14
to pee...@googlegroups.com
Oh, Yes, thx, It's working, but I much more concerned about the fact, that I can't get PeerServer working on my server.

Max Yari

unread,
Mar 11, 2015, 4:01:24 PM3/11/15
to pee...@googlegroups.com
Small update, i get back to establishing peerjs server on express app. This time problem solved. Extremely simple, just by updating my node, express and socket.io to the latest versions. Now everuthing seems to work fine. Thx for this gorgeous project, we yet have no hoverboards, but the future is here.
I'm surprised that they did not mentioned astonishing future of browser peer2peer technologies in the movie.
Reply all
Reply to author
Forward
0 new messages