While deploying node.js with socket.io on Openshift fails with below error : "Waiting for application port (8080) become available ... remote: Application 'meraapp' failed to start (port 8080 not available)"
I want to use this server to connect to my android chat app. below is my server.js
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, path = require('path')
, app = express()
, http = require('http').Server(app)
, io = require('socket.io')(http);
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);
app.set('ipaddr', process.env.OPENSHIFT_NODEJS_IP);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
io.on('connection', function(socket){
console.log('a user connected');
socket.on('new_message', function(data){
console.log('new_message' + JSON.stringify(data));
io.emit('new_message', data);
});
socket.on('login', function(data) {
console.log('login :' + data);
});
socket.on("disconnect", function() {
console.log("disconnect");
});
});
app.get('/', routes.index);
app.get('/users', user.list);
http.listen(app.get('port'), app.get('ipaddr'), function() {
console.log('Socket.IO chat server listening on IP: ' + app.get('ipaddr') + ' and port ' + app.get('port'));
});
please note that I have seen this question : Application failed to start (port 8080) not available but the solutions did not work in my case.