Openshift Nodejs Socket.io问题,但200 Ok响应

我已经在OpenShift Cloud平台中用Red-hat在NodeJs聊天应用程序中部署了下面的代码,我没有在控制台(F12)中得到任何错误,响应代码为OK 200.但是应用程序不工作

服务器(你可以在https://github.com/varund29/openshift/blob/master/index.jsfind完整的源代码)

var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = require('socket.io').listen(server, { origins:'http://nodejs-atnodejs.rhcloud.com:8000' }); app.get('/', function (req, res) { res.sendfile('index.html'); }); io.on('connection', function (socket) { socket.on('chatmessage', function (msg) { console.log('index.js(socket.on)==' + msg); io.emit('chatmessage', msg); }); }); server.listen(process.env.OPENSHIFT_NODEJS_PORT, process.env.OPENSHIFT_NODEJS_IP); 

客户端(你可以在https://github.com/varund29/openshift/blob/master/index.htmlfind完整的源代码)

 src="http://nodejs-atnodejs.rhcloud.com:8000/socket.io/socket.io.js src="http://code.jquery.com/jquery-1.11.1.js" var socket = io.connect('http://nodejs-atnodejs.rhcloud.com:8000'); $('button').click(function (e) { console.log('index.html($(button).click)=' + $('#m').val()); socket.emit('chatmessage', $('#m').val()); $('#m').val(''); return false; }); socket.on('chatmessage', function (msg) { console.log('index.html(socket.on)==' + msg); $('#messages').append($('<li>').text(msg)); }); 

Html的身体是

 <ul id="messages"></ul> <form action=""> <input id="m" autocomplete="off" /> <button>Send</button> </form> 

当我运行你的代码时,我在我的OpenShift Online上的设备上的日志文件中得到以下错误:

 Option log level is not valid. Please refer to the README. Option polling duration is not valid. Please refer to the README. 

所以我在你的index.js文件中注释了以下几行:

 io.set('log level', 1); // reduce logging io.set('transports', ['xhr-polling']); io.set("polling duration", 10); 

现在看起来工作正常。 你可以在这里testing它: http : //nodejs-cdaley.rhcloud.com/你可以在这里查看代码: https : //github.com/developercorey/nodejs