Last Updated: December 14, 2016
· bsorin and OpenShift Websockets works great with OpenShift's websockets. All you need to do is to configure the to use the "websocket" transport.
The rest of transports won't work. = express();
self.server = require('http').createServer(; = io.listen(self.server);{"transports", ["websocket"]);

9 Responses
Add your response
It seems, we have to use the port "8000" and "8443" for websockets.
I've been trying to change this on the client using

io = require('').listen(8000);
var socket = io.connect("http://something:8000");

But request keeps going to port 80 ... Is there any work around for this ?

over 1 year ago ·

On the server side you should use the default port provided by openshift:

self.port      = process.env.OPENSHIFT_INTERNAL_PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080;

In this way I initialized the on the server side:

// initialization on the server side
self.initializeSocketIO = function() {
        self.server = require('http').createServer(; = require('').listen(self.server);'browser client minification');  // send minified client'browser client etag');          // apply etag caching logic based on version number'browser client gzip');          // gzip the file'log level', 1);                    // reduce logging'transports', [
        return this;

    self.addSocketIOEvents = function() {'connection', function (socket) {
          socket.emit('news', { hello: 'world' });
          socket.on('my other event', function (data) {

 *  Initializes the sample application.
self.initialize = function() {

    // Create the express server and routes.

On the client side I used it in this way (index.html):

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<script src="/"></script>
  var socket = io.connect('ws://');
  socket.on('news', function (data) {
    socket.emit('my other event', { my: 'data' });

It should work fine for you. You used a bad port number.

over 1 year ago ·

thanks! helped me!

over 1 year ago ·

Can you explain TO me if I understood well, we have to use different ports on server (8080) and client (8000)???
Thank you
I am a little confused.

over 1 year ago ·

@camillo777 yes. So, for plain WebSockets ws:// you will use port 8000 and for secured connections wss:// port 8443. Here’s an example: <= your current HTTP URL <= WebSockets enables HTTP URL <= your current HTTPs URL <= WebSockets enables HTTPs URL

You can find more details here:

over 1 year ago ·

Did you mean:

Instead of


over 1 year ago ·

@camillo777 yes, you should use ws://

over 1 year ago ·

Hi, did you try it on openshift?
Is your url working? Or is it only an example?

On my site I have a connect/disconnect behavior:

Thank you

over 1 year ago ·

On Server use Port 8080 and start as usual with http or express.
On Client do
NOT: var socket = io.connect(...
DO: var socket = io();

Thats it. Found at heroku and works at OpenShift as well.

over 1 year ago ·