Node.js app on openshift

I have problems with an explicit application that works fine locally

node server.js

      

but has this error on descents:

...

    Uninitialized option at server.js:104:9 events.js:72
    throw er; // Unhandled 'error' event
          ^
    Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1020:19)
...

      

I figured it would be a problem with my .createServer (). My code:

var express = require('express');
var path = require('path');
....//I cut code from here..Bunch of middleware..
var https = require('https');
var http = require('http');

....//My routes were here...
var app = express();

//HTTP
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
http.createServer(app).listen(server_port);

var ssl = {
key: fs.readFileSync('keys/key.pem'),
cert: fs.readFileSync('keys/cert.pem')
};

https.createServer(ssl, app).listen(443);

      

I would also like to work with ssl, but I couldn't find any information on that.

+3


source to share


1 answer


server = require('http').createServer(app)

port = process.env.OPENSHIFT_NODEJS_PORT || 8080  
ip = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";

server.listen(port, ip);

      



Has always worked for me in the past. I'm not entirely sure about rebuilding the stuff you need to match (since yours is almost identical), but its the way it works in my current nodejs app. Also, for further context, you can embed lines from the Uninitialized parameter on server.js: 104: 9 events.js: 72, if you've already done that, can you tag them? from what I see your stuff should work.

+4


source







All Articles