Error: Invalid protocol - node.js

I am facing this issue while making a request to any url using NodeJS.
FYR i have made a script in nodejs which is using request module that calls a page and then scrap that html page but the issue is when it calls i gets an error "Error: Invalid protocol: 10.112.62.78".
My .npmrc file contains following lines
proxy=http://10.112.62.78:8080
https-proxy=http://10.112.62.78:8080
registry=http://registry.npmjs.org/
and i still get following error
[Error: Invalid protocol: 10.112.62.78:]
I have tried all possible combinations of following
http://user:password#proxy:port
http://"user:password"#proxy:port
For the above two i get "URI Malformed error"
Still no solution
http://proxy.company.com:port
FYI Versions are as follows:
>node -v
>v0.12.0
>npm -v
>2.5.1
There is one more info i have static ip of 10.112.111.86 in IPv4 and ip of 10.112.62.78 with 8080 in Proxy Setting of Browser . Also i am using Windows 7 desktop and i tried with Proxy IP of 10.112.62.78 & without it but no solution however i can't change the IPv4 otherwise my internet connection would be gone.
Please provide some solution i am stuck.
PS: Also tried by changing http To https for https-proxy .

Npmrc is used by npm, not (afaik) requests within your node code, so this is probably a red herring. What code are you using to make the request?

Related

NodeJs API msrestazure proxy issue

I've a nodejs api that uses npm package msrestazure.
From my local development I've to pass via enterprise proxy to get to the internet.
When I try msRestAzure.loginWithServicePrincipalSecret I get a connection timeout due to the fact that request doesn't use the proxy.
Error: connect ETIMEDOUT 52.143.136.20:443
If someone knows how I can force the usage of the proxy tell me.
For info i've tested multiple solution
set proxy environment variable : not running
use netsh winhttp to set proxy : not running
use software proxycap : it runs. But software is not free and can't request to other developper to use it.
Any has an idea ?? Issue is only for request done by the package.
If i use http request to do the request my self, it works :(
Thanks for your help
sorry for delay ...
Solution is to use package npm dotenv and add HTTP_PROXY and HTTPS_PROXY variable in it.
Hope that can help :)

How can I access my nodejs web server from my local computer using the server domain name?

I installed nodejs and created a sample app. When I run npm start I get a message saying that I can open my web browser to http://localhost:3000 to see the app in action, but this installation is on a web server - not my local computer, so, instead of localhost:3000 I want to get there using something like mydomain.com:3000
I can't find the answer, it's very likely I just don't know how to search for it... any ideas?
I'm following the tutorial here: https://facebook.github.io/react/tutorial/tutorial.html
I think I only needed to get away from this for a while. I got it working using ssh local forwarding.
I already used an ssh config file to log in to my server without having to remember the password, so I just added this line to my config file:
LocalForward localhost:3000 xxx.xxx.xxx.xxx:3000
where xxx.xxx.xxx.xxx is my server IP address.
Then, I connected to my server via ssh:
ssh -f -N mysite
Once connected, I open up the browser and go to localhost:3000 and there it is now.
I used my ssh config file, but it should also work without it.
ssh -f -N -R 3000:localhost:3000 mydomain.com
I found this command that eventually led me to solve my problem in this link: http://stuff-things.net/2016/01/20/tunneling-to-localhost/

Access watson retrieve and rank behind a proxy in Node

I need to know if the R&R service can be used behind a proxy.
Take a look at the next part to see my investigations.
The code I'm using was working at my home. (No firewall/No Proxy, only a router)
I started from the following code.
https://console.eu-gb.bluemix.net/catalog/starters/personality-insights-nodejs-web-starter
I try to execute it locally and it was working using the following configuration to be able to install the modules.
npm config set registry http://registry.npmjs.org
npm config set proxy http://x.x.x.x:xx
npm config set https-proxy http://x.x.x.x:xx
npm config set strict-ssl false
set http_proxy=http://x.x.x.x:xx
set https_proxy=http://x.x.x.x:xx
set HTTP_PROXY=http://x.x.x.x:xx
set HTTPS_PROXY=http://x.x.x.x:xx
As it was working I started playing around with R&R. But I'm only having an error.
Error searching for documents: Error: connect ETIMEDOUT 158.85.132.88:443
Where the ip address corresponds gateway.watsonplatform.net
ping gateway.watsonplatform.net
PING gateway.watsonplatform.net (158.85.132.88) 56(84) bytes of data.
Because of the firewall the ping are blocked
During my investigations I found that when executing my test for the R&R service every time two ICMP request are send.
Probably because of the firewall. But why this service would need to send ICMP packets ?
Just to recap:
The code is working when there is no firewall/no proxy
The personnality Insight service is working behind proxy/firewall
The R&R isn't
EDIT
After some investigations I've found that there was a bug in the Solr-client so it is currently impossible to make it work.
More info here on this github issue.

Installing Express in Node.js

I am getting error while installing Express to use in Node.js
I have attached screenshot of the command prompt.
I am not getting what this error is. Please let me know what this error say, so that I can fix it.
Possible problems:
no internet connection
DNS resolver misconfigured
proxy settings required
You can try the following commands to narrow down the problem:
host registry.npmjs.org
ping registry.npmjs.org
curl http://registry.npmjs.org/
curl https://registry.npmjs.org/

Getting ECONNRESET response using node's http.get function

I finally figured out what was causing this problem and didn't find any direct answers online, so I thought I'd post an answer (below). Anyway, here's the problem:
I have a simple node app running on port 3000. I was trying out some database connection pooling, and I wanted to load test it to make sure it was working the way I expected. I installed siege and tried:
$ siege -c 10 -r 10 -b http://localhost:3000
I got a Connection reset by peer error. So I tried reducing the number of connections:
$ siege -c 1 -r 1 -b http://localhost:3000
Same problem. I thought maybe it was a problem with siege, so I tried nperf and got a ECONNRESET error. Same with artillery.
The weird thing is that I could connect using curl, telnet, and the web browser and got a valid response.
I tried logging errors in the express app, but it never seemed to receive a request. I tried monitoring network traffic using nettop, but it never showed a connection using siege or nperf (though it did using curl).
I wrote a client app to connect using the same method that nperf uses (node's http.get function), and got the same ECONNRESET response.
I wrote a simple express app running on port 3001 and it worked fine! I tried commenting out most of the lines in my port 3000 app so it was basically the same as my 3001 app, but it still didn't work. I was beginning to suspect that webpack was doing something strange, and then finally started to realize...see answer below.
Maybe there's another program on port 3000!
So, I ran:
$ sudo lsof -i -P | grep -i "listen"
and I found an old VM I'd forgotten to halt, that had port 3000 exposed (another project). I shut it down and everything worked great!
I thought node warned if a port was being used, but for some reason it didn't notice this one.
Anyway, if you're getting a similar error, do a port scan!

Resources