I have a long procedure I have written in node.js, but I'd like the PHP side of my application control kicking it off. My node is something like:
var http = require('http');
http.createServer(function (req, res) {
console.log('Got request')
try{
doProcedure()
} catch(e) {
console.log('Really bad error while trying to do the procedure:')
console.error(e.stack ? e.stack : e)
}
}).listen(8124, "127.0.0.1");
When I run this on my local machine, http://localhost:8124 will trigger things correctly. On aws, I've added the 8124 port but requests to mydomain.com:8124 aren't picked up by node.
I tried stopping httpd and then letting node listen on port 80, to rule out ports not being forwarded correctly, but it still saw nothing.
So two questions, I guess:
Bonus question: Is there a better way I should be doing this?
Thanks all,
~Jordan
If you omit the second argument to listen(), node will listen on all IP addresses. That way you can run the same code locally to test and also on your EC2 instance.
In your catch block, you might also want to send back an HTTP error response to the client.
you should have a 10.* ip iirc for aws, your elastic/dynamic ip cant be bound to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With