Sorry I am new to Docker and I am trying to learn the basics while playing around, basically I am having issue while making internal API calls between two nodeJs services.
So I have two nodeJs servers running as service with 2 replicas of both the services and what I want to achieve is to make an API call to node server A from browser and in turns server A make another API call to node server B and sends a dummy data back to server A and server A returns it to browser.
Now above works fine as expected when I run both the servers without docker.
node server A
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
image: nodeone:first
deploy:
replicas: 2
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "4000:3000"
networks:
- nw1
networks:
nw1:
node server B
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
image: nodetwo:latest
deploy:
replicas: 2
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "4080:3080"
networks:
- nw1
networks:
nw1:
nw1 is a custom network.
I tried to call server B from inside server A with below configurations and nothing seems to work.
- "http://localhost:4080/nodeACalling"
- "http://nodeBServiceName:4080/nodeACalling"
- "http://nodeBServiceName:3080/nodeACalling"
and in all the above cases I am getting below error
error: { Error: connect ECONNREFUSED 10.0.6.2:4080 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14) errno: 'ECONNREFUSED',