Failed to connect to duckling http server. Make sure the duckling server is running and the proper host and port are set in the configuration - python-3.x

I have made workplace on slack and app is registered there from where i get the necessary things like slack token and channel to put it into the credentials.yml file of the rasa. After getting all the credentials i tried to connect between the rasa bot and slack using the command as:
rasa run
and my credentials.yml contains:
slack:
slack_token: "xoxb-****************************************"
slack_channel: "#ghale"
Here i have used the ngrok to expose a web server running on your local machine to the internet
but getting the error :
rasa.nlu.extractors.duckling_http_extractor - Failed to connect to duckling http server. Make sure the duckling server is running and the proper host and port are set in the configuration. More information on how to run the server can be found on github: https://github.com/facebook/duckling#quickstart Error: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /parse (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

Are you using Duckling? Duckling is a rule-based component to extract entities(docs).
If you are not using it, you can remove it from your NLU pipeline.
If you want to use it, the easiest way to do so is using docker:
docker run -p 8000:8000 rasa/duckling
The command above will run duckling and expose it on port 8000 of your host.

Just to add to #Tobias's answer;
If you are running some other service on port 8000, then you can bind any other port with th container's port and specify that in your pipeline config.
Example:
docker run -p <Desired Port, ex- 1000>:8000 rasa/duckling
Change config file to reflect that. Your pipeline should include
- name: DucklingHTTPExtractor
# https://rasa.com/docs/rasa/nlu/components/#ducklinghttpextractor
url: http://localhost:<Desired Port, 1000>
Retrain your model with changed config.
After training, simply run: rasa run

If you are doing numerical extractions (e.g. six to 6 etc), I presume this will be helpful for form filling on Rasa - you need to install docker and then expose duckling on port 8000
First, install docker (assumes Fedora but you can lookup other distros)
sudo dnf install docker
Second, activate docker
sudo systemctl start docker
Last, activate Rasa's docker
docker run -p 8000:8000 rasa/duckling
Your response should be - Status: "Downloaded newer image for
docker.io/rasa/duckling:latest Listening on http://0.0.0.0:8000"

Related

Unable to communicate between docker and external service

I have a docker container running in localhost:3000
Also, I have a node app running in localhost:8081
Now if I want to make post or get request from localhost:3000 to localhost:8001 its not working at all.
Now if run the service as a binary (not a docker file) on localhost:3000 the same API requests works.
How do I communicate if using docker?
Each container runs on it's own bridge network where localhost means the container itself.
To access the host, you can add the option --add-host=host.docker.internal:host-gateway to the docker run command. Then you can access the host using the host name host.docker.internal. I.e. if you have a REST service on the host, your URL would look something like http://host.docker.internal:8081/my/service/endpoint.
The name host.docker.internal is the common name to use for the host, but you can use any name you like.
You need docker version 20.10 for this to work.

ERR_NAME_NOT_RESOLVED using Docker network to communicate between a backend container and a React container

I have a backend up (NodeJS) which is the listening on some port (2345 in this example).
The client application is a React app. Both are leveraging socket.io in order to communicate between themselves. Both are containerized.
I then run them both on the same network, using the "network" flag:
docker run -it --network=test1 --name serverapp server-app
docker run -it --network=test1 client-app
In the client, I have this code (in the server the code is pretty standard, almost copy-paste from socket.io page):
const socket = io.connect('http://serverapp:2345');
socket.emit('getData');
socket.on('data', function(data) {
console.log('got data: ${data}');
})
What I suspect is that the problem has to do with having the client (React) app served by the http-server package, and then in the browser context, the hostname is not understood and therefore cannot be resolved. When I go into the browser console, I then see the following error: GET http://tbserver:2345/socket.io/?EIO=3&transport=polling&t=MzyGQLT net::ERR_NAME_NOT_RESOLVED
Now if I switch (in the client-app) the hostname serverapp to localhost (which the browser understands but is not recommended to use in docker as it is interpreted differently), when trying to connect to the server socket, I get the error: GET http://localhost:2345/socket.io/?EIO=3&transport=polling&t=MzyFyAe net::ERR_CONNECTION_REFUSED.
Another piece of information is that we currently build the React app (using npm run build), and then we build and run the Docker container using the following Dockerfile:
FROM mhart/alpine-node
RUN npm install -g http-server
WORKDIR /app
COPY /app/build/. /app/.
EXPOSE 2974 2326 1337 2324 7000 8769 8000 2345
CMD ["http-server", "-p", "8000"]`
(So, no build of the React app takes place while building the container; we rather rely on a prebuilt once)
Not sure what I am missing here and if it has to do with the http-server or not, but prior to that I managed to get a fully working socket.io connection between 2 NodeJS applications using the same Docker network, so it shouldn't be a code issue.
Your browser needs to know how to resolve the SocketIO server address. You can expose port 2345 of serverapp and bind port 2345 of your host to port 2345 of serverapp
docker run -it --network=test1 -p 2345:2345 --name serverapp server-app
That way you can use localhost in your client code
const socket = io.connect('http://localhost:2345');
Also get rid of 2345 from your client Dockerfile

docker container cannot connect to localhost mongodb [duplicate]

This question already has answers here:
Connect to host mongodb from docker container
(4 answers)
Closed 4 years ago.
A. I have a container that includes the following
1. NodeJS version 8.11.4
2. Rocketchat meteor app
B. This is my Dockerfile
FROM node:8.11.4
ADD . /app
RUN npm install -g node-gyp
RUN set -x \
&& cd /app/programs/server/ \
&& npm install \
&& npm cache clear --force
WORKDIR /app/
ENV PORT=3000 \
ROOT_URL=http://localhost:3000
EXPOSE 3000
CMD ["node", "main.js"]
C. This command is executed well
docker build -t memo:1.0 .
When I try to run the container, it encounters the following error in containers log
{"log":"MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]\n","stream":"stderr","time":"2019-01-24T21:56:42.222722362Z"}
So container can not be executed.
The mongodb is running and I've added 0.0.0.0 to bindIp in the mongod.conf file.
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
My mongodb is installed in host(outside the container)
The problem was not resolved and my container status is Exited
I put the IP instead of the localhost,but it encounters the following error
{"log":"MongoNetworkError: failed to connect to server [192.168.0.198:27017] on first connect [MongoNetworkError: connect EHOSTUNREACH
The problem here is that you're starting a docker container (a self contained environment) and then trying to reach localhost:27017. However, localhost inside your container is not the same localhost as outside your container (on your host). There are two approaches you could take from this point:
Instead of attempting to connect to localhost:27017, connect to your host's ip (something like 192.x.x.x or 10.x.x.x)
(Better option imo) dockerize your mongodb, then your services will be able to communicate with each other using docker dns. To do this, you would create a docker-compose.yml with one service being your app and the other being mongodb.
When you try with MONGO_URL=mongodb://192.168.0.198:27017/rocketchat add that IP to bindIp as well.
With localhost MONGO_URL=mongodb://127.0.0.1:27017/rocketchat
I also recommend enabling security authorization in mongo config. Then set a user and password for your database.
Keep in mind that any change to config file requires a mongo restart

Socket connection into Docker initially succeeds then fails

Running under MacOS I am connecting from a node.js app with net.Socket() into a Docker container running on the same host, which contains a C++ sockets server under Centos. The Docker run command is:
docker run -it --rm -p 14000-14010:14000-14010 -v /Users/me/Development/spdz:/spdz spdz/spdzdev
When the c++ server in docker is not running, I see a successful connection in node followed 3ms later by a socket closed message.
It appears as if a proxy in front of the container is accepting the request, passing it through to Docker where it is rejected. However this leads to erroneous messages in my front end application which thinks the connection was successful, only to find out later it was not.
I would like to see a simple connection declined. Any suggestions as to how this may be remedied or better understood would be helpful.
I am confident that the behaviour is introduced by Docker, as running the components outside Docker gives the expected immediate failure on connection. Also I have tried mapping the exported ports to an external network interface rather than localhost but see the same behaviour.
I suggest that you check that if the error is not coming from your server application.
You can use netcat command line to open a socket on your Docker container
nc -l 14000
This will create a TCP server socket listening on port 14000.
Then, from your host computer (MacOs), open a terminal and try to connect with telnet
telnet -e q localhost 14000

Can't get docker to accept request over the internet

So, I'm trying to get Jenkins working inside of docker as an exercise to get experience using docker. I have a small linux server, running Ubuntu 14.04 in my house (computer I wasn't using for anything else), and have no issues getting the container to start up, and connect to Jenkins over my local network.
My issue comes in when I try to connect to it from outside of my local network. I have port 8080 forwarded to the serve with the container, and if I run a port checker it says the port is open. However, when I actually try and go to my-ip:8080, I will either get nothing if I started the container just with -p 8080:8080 or "Error: Invalid request or server failed. HTTP_Proxy" if I run it with -p 0.0.0.0:8080:8080.
I wanted to make sure it wasn't jenkins, so I tried getting just a simple hello world flask application to work, and had the exact same issue. Any recommendations? Do I need to add anything extra inside Ubuntu to get it to allow outside connections to go to my containers?
EDIT: I'm also just using the official Jenkins image from docker hub.
If you are running this:
docker run -p 8080:8080 jenkins
Then to connect to jenkins you will have to connect to (in essence you are doing port forwarding):
http://127.0.0.1:8080 or http://localhost:8080
If you are just running this:
docker run jenkins
You can connect to jenkins using the container's IP
http://<containers-ip>:8080
The Dockerfile when the Jenkins container is built already exposes port 8080
The Docker Site has a great amount of information on container networks.
https://docs.docker.com/articles/networking
"By default Docker containers can make connections to the outside world, but the outside world cannot connect to containers."
You will need to provide special options when invoking docker run in order for containers to accept incoming connections.
Use the -P or --publish-all=true|false for containers to accept incoming connections.
The below should allow you to access it from another network:
docker run -P -p 8080:8080 jenkins
if you can connect to Jenkins over local network from a machine different than the one docker is running on but not from outside your local network, then the problem is not docker. In this case the problem is what ever machine who is receiving outside connection (normally your router, modem or ...) does not know to which machine the outside request should be forwarded.
You have to make sure you are forwarding the proper port on your external IP to proper port on the machine which is running Docker. This can be normally done on your internet modem/router.

Resources