Subtiv Subtiv - 2 years ago 481
Javascript Question

Websocket failure in openshift / nodeJS

I know quit some similar questions have been asked here, however none of the proposed solutions seem te work. (I'll post relevant answers below)

I can't get a simple websocket app to work on openshift. The app itself works locally.
[Edit: i'm using]

The relevant code:


var express = require('express');
var app = require('express')();
var server = require('http').Server(app);
var io = require('').listen(server);

server.listen(process.env.OPENSHIFT_NODEJS_PORT, process.env.OPENSHIFT_NODEJS_IP);

io.on('connection', function (socket) {



<script src="/"></script>


this.socket = io.connect('', {'forceNew':true });


  • GET http://****-**** net::ERR_CONNECTION_TIMED_OUT *

Stuff I tried

use port 80 instead of 8000 (on client)

WebSocket connection to 'ws://' failed: Error during WebSocket handshake: Unexpected response code: 400

Interchange server.list(… and var io = require('…

no result

Use ip address of server instead of

no result

Similar questions

The following questions kind of deal with the same issue, however none of the proposed solutions worked so far and node on OpenShift

OpenShift NodeJS deployment : index.html port assignment, etc

unable to deploy nodejs socket io application on openshift

Can't get and nodejs running with OpenShift returns 404 on OpenShift

Also I cloned some github examples of but all of them kind of deal with the same issue.

Either I'm doing something completely wrong or something funny is going on over at openshift.

Thanks in advance.

[EDIT] : As suggested by Xodrow

this.socket = io('...', {forceNew: true, transports: ['websocket']});

doesn't really change anything

Answer Source

I've finally cracked it. Apparently by hardcoding the transport-configuration on the server side it works.

var io = require('', {
        transports: ['websocket']

Hope this helps someone in the future.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download