这是我的代码:
var express = require('express');
var net = require('net');
var app = express();
var sock;
//first of all connect to a stable client
console.log('waiting for connection\nfrom mobile server on port 5132');
var server = net.createServer(function(socket) {
sock = socket;
});
server.listen(5132);
//receive request from other clients
app.get('/', function(req, res) {
// retriving mobileNumber and message
console.log('A new request\nreceived on 6544 ');
var mobileNumber = req.query.mobileNumber;
var message = req.query.message;
if (sock) {
sock.write(mobileNumber + "\n" + message + "\n");
res.write(" Wah yyaar...");
}
res.end('i am ended');
});
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
app.listen(server_port, server_ip_address);
这是错误:
Git Post-Receive Result: failure
Activation status: failure
Activation failed for the following gears:
56ce93357628e1c35b0000ff (Error activating gear: CLIENT_ERROR:
Failed to execute: 'control start' for
/var/lib/openshift/56ce93357628e1c35b0000ff/nodejs
#<IO:0x00000001d7a388>
#<IO:0x00000001d7a310>
)
Deployment completed with status: failure
我认为问题是由于端口5132
但是解决方案是什么?
答案 0 :(得分:2)
您正尝试在所有地址(0.0.0.0)或不允许的环回(127.0.0.1)上绑定到端口5132。您需要使用您用于端口8080绑定的IP地址,如:
server.listen(5132,process.env.OPENSHIFT_NODEJS_IP);