Skip to content

Instantly share code, notes, and snippets.

@kevinSuttle
Last active September 6, 2018 12:13
Show Gist options
  • Save kevinSuttle/85b3b6c6d480c3842242 to your computer and use it in GitHub Desktop.
Save kevinSuttle/85b3b6c6d480c3842242 to your computer and use it in GitHub Desktop.
Socket.io, Express-generator troubleshooting
var express = require('express'),
https = require('https');
//...
var app = express();
// ...
module.exports = app;
window.onload = function() {
socket = io.connect('http://127.0.0.1:3333');
socket.on('connect', function () {
socket.send('hi');
});
}
#!/usr/bin/env node
var debug = require('debug')('app:www');
var app = require('../app');
var server = require('http').createServer(app);
var io = require('../io');
var localHost = 'http://127.0.0.1'
var localPort = '3333';
app.host = app.set('host', process.env.HOST || localHost);
app.port = app.set('port', process.env.PORT || localPort);
var server = app.listen(app.get('port'), function() {
app.address = app.get('host') + ':' + server.address().port;
console.log('Express server listening at ' + app.address);
});
io.attach(server);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment