2
votes

I have a simple chat application based on nodejs and socket io. Works fine locally. But i am facing issues in deploying it to openshift.

I have read and implemented almost all related threads on Stack Overflow. No progress yet.

Client Side(index.html):

<script src="/socket.io/socket.io.js"></script>
var socket = io.connect("http://www.abcd.com:8000/"); 

where 'abcd' is an attached domain name to the openshift app.

Server Side(index.js):

//Express initializes app to be a funciton handler that is to be supplied to the http server later
var express = require('express');
var app = express();
//
var server = require('http').Server(app);
var io = require('socket.io')(server);
var mongoose  = require('mongoose');

var server_port = process.env.OPENSHIFT_NODEJS_PORT || 3000
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'

//server listening
server.listen(server_port, server_ip_address, function(){
  console.log('listening on *:'+server_port);
});

I have done the following already:

  • Changing the client side URL to: ws://www.abcd.com:8000/
  • replacing io.connect with io
  • switching the port to 80
  • and a lot of other things.

ERROR:

1

1 Answers

0
votes

It looks to me like you aren't binding your websockets to the ip & port, after your server.listen, try this:

var socket = io.listen(server);