Access watson retrieve and rank behind a proxy in Node - node.js

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.

Related

How to fix ETIMEDOUT error after npm install?

This is the error I receive:
I get similar errors in other projects as well after npm install.
First make sure that the server you are trying to access is up. The address is a little sketchy. Ping should do the trick:
$ ping http://bbdr.dcc.com.de:5005
If pinging is successful, make sure that your firewall is not blocking traffic.
If you are behind a proxy, check if $ ping http://bbdr.dcc.com.de:5005 works.
And if you are not behind any proxy, then try below commands -
npm config delete proxy
npm config delete http-proxy
npm config delete https-proxy

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 :)

Intercept outgoing HTTP requests to npmjs.org, etc

I am looking to create a locally running Node.js server that can intercept outgoing requests to the NPM registry (npmjs.org, or whatever).
Is that what a reverse proxy is?
Basically what I would like to do is create a locally running NPM registry - this is for use with locally running Docker containers. Normally I would just use npm link for local development. But when testing libraries using Docker locally, using npm link for that becomes hard to impossible
I know there are some libraries out there that set up a local NPM registry, but I am looking to do this from scratch so I can set it up for my use case. Essentially I want to tarball packages that exist on my filesystem each time an npm install request comes in.
I started experimenting with:
npm config set registry http://localhost:3440
but when I subsequently did an npm install, it didn't seem to hit my locally running server, just went to registry.npmjs.org like normal.
I also tried modifying /etc/hosts
before:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
after:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
registry.npmjs.org localhost:3440
but my local server listening on port 3440 did not seem to intercept any traffic.
That's not a reverse proxy, but that's a forward proxy. And you'll effectively have to use npm config set proxy to use it from npm call.
The main tool used for such proxy is usually squid proxy. And I'm pretty sure you can build more robust and feature-full service using some well known forward proxy tools instead of a custom nodejs tool.
Then you'll have to check where this service is running (on the same docker? on another docker? on your host?). The address you set for npm, in npm config set proxy must be resolvable from inside the container running npm (but it may differ between commands running on the Dockerfile step and commands running in a bash session after that build).

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/

Error: Invalid protocol

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?

Resources