I have a Node.js/Express application which I'm trying to deploy to Openshift.
The server itself starts up properly and serves almost everything.
One request to the server opens up a Zombiejs browser, which then crawls some webpages.
When the browser tries to visit a webpage however, I get this error:
{ [Error: bind EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'bind' }
Possibly unhandled Error: bind EACCES
at errnoException (net.js:901:11)
at connect (net.js:747:21)
at net.js:842:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
The browser fails as soon as I call visit:
browser.visit(menus_url).then(function () {
// do things
});
Before doing the above, I start an Express-based server as follows:
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP;
app.listen(server_port, server_ip_address, function() {
console.log('Server running on port ' + server_port);
});
The server starts up fine, however as soon as I make a request that calls browser.visit() the error is raised.
Update 11/15
I still haven't found a solution to this issue.
When the browser is created, it tries to use the ip address of 0.0.0.0 to bind to (https://github.com/assaf/zombie/blob/master/src/zombie/browser.coffee#L1224) by default, which is not available on OpenShift for your use, you need it to bind to your OPENSHIFT_NODEJS_IP ip address, just like you use for your express server. It looks like, at the top of the file that I linked to (https://github.com/assaf/zombie/blob/master/src/zombie/browser.coffee#L42), that one of the Browser options you can pass in is 'localAddress' when creating the Browser object, which should be the OPENSHIFT_NODEJS_IP. I think that will get it fixed up for you.
Related
I'm developing an Office.js add-in for Excel, and I'm kind of lost on how to create the server side of the application and test it on localhost.
I've created the add-in project/structure using Yo Generator, and I'm using gulp to test it on localhost (port:8443). Using this approach, I was able to successfully load my add-in and test the client-side of the same. Also, I've tested a http request to a static json file and it worked fine.
The issue is that I need to run code on server side for dealing with files and doing some processing, and I simply can't find a way to do that.
I've already tried to start a localhost server on a different port (port:8000) using the code bellow and node command:
var https = require('https');
var fs = require('fs');
var httpsOptions = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
var app = function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}
https.createServer(httpsOptions, app).listen(8000);
The server started ok, but as my application is running on port:8443, I'm unable to do cross origin requests (which I understand would also not work on a production environment).
I also tried to start add-in server on port:8443 using gulp serve-static command, and then start a server listening on the same port:8443 using node command, but this results on the error bellow:
Error: listen EADDRINUSE 127.0.0.1:8443
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at net.js:1379:9
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:64:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:83:10)
May someone please help on how to get this working?
Please let me know if any further information is required.
Thanks in advance.
First, you can't have two servers listening on the same port simulateneously. That's why you're getting the Address in Use error.
Second, I am in a similar situation like you and my thinking here was, that the way to go would be writing a server that provides an API (e.g. REST). Then, the javascript code that get's loaded into office (for starters the App.js in your yo office generated project) makes requests to this API.
So I have a web service running on port 7001 over TCP on:
net.tcp://www.myurl.com:7001/my/webservice
and I want to connect to it using net.Socket:
client.connect(7001, 'myurl.mine.com/my/webservice', function () {
console.log('Connected');
client.write(msg);
});
When i do the above, it gives an exception:
Error: getaddrinfo ENOTFOUND <<my url>>
at GetAddrInfoReqWrap.onLookup [as oncomplete]
when i try connect to it without the /my/webservice, it connects fine and doesnt give an error at the client.connect() stage, but obviously cant find that endpoint so it gives another error when i try to do the client.write()
Any one any idea how to use net.Socket against a web service with a url that isnt just myurl.com:7001 but actually contains a route like myurl.com:7001/my/webservice?
According to node.js docs the version of the method you are using expects only a hostname for a second argument. You are providing hostname + path
In your case I would recommend using a more generalized version of net.connect which accepts an object with parameters. So your code will look something like this:
client.connect({
host: 'myurl.mine.com',
port: 7001,
path: '/my/webservice'
},
function () {
console.log('Connected');
client.write(msg);
}
);
I have a web app setup using nodejs and mongodb and backbonejs.
When I run my app remotely and try to redirect to a different route through the uri, for example: http://www.myapp.com/route I get a net error.
In my route.js file I have the following:
var mongodb = require('mongodb');
var db = new mongodb.Db('dbname', new mongodb.Server('xx.xx.xxx.xxx', 27017, {}));
where xx.xx.xxx.xxx is my public ip. However, when I change this to anything other than "localhost" and try to run node server.js in the root of my app I get the following error:
Listening on port 3000...
/var/www/html/pages/node_modules/mongodb/lib/server.js:236
process.nextTick(function() { throw err; })
^
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1012:19)
I have already uncommented bindIp in my /etc/mongod.conf file as suggested in other posts. I did this only to test and just to get it to work, but I plan to go back and play with the ip tables if I get this to work.
How can I access my app remotely?
I am relatively new to both node and TOR. I'm trying to send a request using a node application through TOR. Ive set up a basic app using socks5-HTTP-client. Also, TOR is installed (sudo port install tor) and I ran the server using tor..
Executing the app, node gives me the following error
Error: SOCKS connection failed. General SOCKS server failure.
at Socket.<anonymous> (/Users/MyName/node_modules/socks5-client/lib/Socket.js:199:12)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
The TOR server reports the following to me:
[warn] Rejecting SOCKS request for anonymous connection to private address [scrubbed].
The topic I found here does not seem to apply to this case. Also, this earlier article does not answer my question. Neither can I find any difference between the example given by the developer of the socks5 module and my case.
I am unsure whether this is an issue with my configuration in node or my TOR configuration.
Below is the JS code
var shttp = require('socks5-http-client');
var config =
{ url: 'http://whatismyipaddress.com/', // I'd like to see a different IP on every request, that should be the end result, correct?
socksHost: '127.0.0.1',
socksPort: 9050
}
shttp.get(config, function(res) {
res.setEncoding('utf8');
res.on('readable', function() {
console.log(res.read());
});
});
Also, in my torrc.sample configuration file, I made sure the following is set up:
SOCKSPort 127.0.0.1:9050
Also, my SOCKSPolicy is set up as follows:
SOCKSPolicy accept 192.168.0.0/16
SOCKSPolicy accept6 FC00::/7
SOCKSPolicy reject *
At the time of trying, my internal IP address was 192.168.0.11, seems fine to me.
Any help would be appreciated!
You are getting that error because the URL isn't getting passed to the request properly so it is trying to issue a SOCKS request to localhost instead of the site you want to visit.
URLs are parsed using url.parse.
Try changing your code to:
var shttp = require('socks5-http-client');
var url = require('url');
var config = url.parse('http://whatismyipaddress.com/');
config.socksHost = '127.0.0.1';
config.socksPort = 9050;
shttp.get(config, function(res) {
res.setEncoding('utf8');
res.on('readable', function() {
console.log(res.read());
});
});
Also, it appears whatismyipaddress.com might be blocking Tor as I don't get a response back from them. Try ipchicken.com or some other site. You may need to set a User-Agent header to get the former site to reply, but this code change does work.
I am building a node.js/express app which makes remote calls to other internal web application (ASP.NET WEB API) to consume json from it. We are in a corporate network. Here is the strange issue.
On my Mac OSX (Mavericks), I can curl from shell and get json from http://our_internal_host:9991/connections. I can also type this URL and see the JSON response from the browser.
When I run this express app locally and request the route which makes the remote call, I see this error on the console. The route handler logs this message below and browser hangs.
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
Node process cannot make a connection to that address. I also have a Windows 7 machine at work and I do not encounter this issue on my Windows 7 machine. When I run the same node app on Windows 7, I don't have any issues.
I am not sure how to troubleshoot the issue...
PS: A colleague of mine who has the same setup doesn't have this issue. We compared DNS configs but our setup looks to be same.
Any pointers to troubleshoot this issue is much appreciated. I know this is environment specific issue but not sure where to start.
Thanks
EDIT #1
Route handler making the remote call which logs the error above...
var http = require('http');
var options = {
host: 'our_internal_host',
port: 9991,
path: '/analytics'
};
http.get(options, function(res) {
// removed response code
console.log(res);
}).on('error', function(e) {
console.log(e);
});
It turns out my Mac's IP was on a different subnet than other machines.