simplewebrtc / SimpleWebRTC

Simplest WebRTC ever

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is Express Required When Running Signaling Server

vinodmap opened this issue · comments

I am having problems with my signaling server. I have followed steps 1-4 at https://github.com/andyet/signalmaster. I get {"code":0,"message":"Transport unknown"} when I go to http://localhost:8888/socket.io/. I have generated certs. I then have set NODE_ENV=production. Then on a separate line, I run node server.js. The server runs. However, using this with SimpleWebRTC is not working correctly. Am I able to run this just by doing "node server.js" or is it required to use Express as specified at https://github.com/andyet/signalmaster ? That would be:

var express = require('express')
var sockets = require('signalmaster/sockets')
var app = express()
var server = app.listen(port)
sockets(server, config) // config is the same that server.js uses

Please let me know if it is required to use Express, and if that is indeed part of the problem I am having. Thank you.

I finally got my signaling server to work (barring any other issues that comes up). To me, while the instructions on this site are correct, they are not complete. I created an index.js file with the contents below (BTW, I changed the port from 8888 to 443):

var express = require('express')
var https = require('https')
var http = require('http')
var fs = require('fs')
var config = require('getconfig')
var sockets = require('./sockets')

var options = {
        key: fs.readFileSync(config.server.key),
        cert: fs.readFileSync(config.server.cert),
        passphrase: config.server.password
};


var app = express()
var server = https.createServer(options, app).listen(443);
sockets(server, config) // config is the same that server.js uses

I am no longer running "node server.js" as in the instructions. Instead, I am just running the index.js file that I created by doing "sudo node server.js &". Also note, by doing this, when I go to http://localhost:443/socket.io/, I still get {"code":0,"message":"Transport unknown"}

So to answer this question (my question), you DO need to use Express. When running with Express, when I Wireshark my connection, I now see Client and Server hello messages, which I was not seeing when you just run it with "node server.js". Lastly, I did not have to run it with Docker to get this to work.