I am trying to run some integration tests in my Jenkins pipeline connecting to a mysql docker container. For some reason, we can't connect to it. We have checked that the credentials are right and that the port is exposed to the host:
mysql:5.6 0.0.0.0:3360->3306/tcp mysql
Our Jenkins runs in a host, it isn't a docker container.
I have inspect the container, and everything is the same as in my local environment, where I can connect to the container. This is the error I am getting:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Any idea what it could be?
Thanks in advance.
Related
I have reserved a number of Linux based EC2 machines(running OS : Centos 7) and with the exact same versions of JMeter 4.0 and Java installed.
No active firewalls, all the devices are connected within the same subnet and I can easily ping between them.
The problem is that I when I try to configure a mater machine and connect it to one of my slaves I keep receiving this exception
Connection refused to host: xx.yy.zz.4; nested exception is:
java.net.ConnectException: Connection timed out (Connection timed out)
Failed to configure xx.yy.zz.4
Stopping remote engines
Remote engines have been stopped
Error in NonGUIDriver java.lang.RuntimeException: Following remote engines could not be configured:[xx.yy.zz.4]
I have made my slave(ip: xx.yy.zz.4) setup as follows:
server_port = 24000 , server.rmi.localport=26000 , server.rmi.ssl.disable=true, No Remote Hosts and I usually launch the server using this shell command:
./jmeter-server -n -Djava.rmi.server.hostname=xx.yy.zz.4
And for the master which is also another EC2 instance(ip: xx.yy.zz.21) I made these configurations:
remote_hosts=xx.yy.zz.4:24000 , client.rmi.localport=25000, server.rmi.ssl.disable=true
And I use this shell command to start my JMeter's test plan
./jmeter -n -Rxx.yy.zz.4 -t /home/centos/jmeter/scripts/demo.jmx -Djava.rmi.server.hostname=xx.yy.zz.21
Any idea on what might cause these error?
Minimal configuration:
slave:
./jmeter-server -Dserver_port=24000
master:
./jmeter -n -R xx.yy.zz.4:24000 -t test.jmx
More information:
How to Perform Distributed Testing in JMeter
Remote hosts and RMI configuration
Also be aware that according to JMeter Best Practices you should be always using the latest JMeter version so consider upgrading to JMeter 5.2.1 (or whatever is the latest stable version available at JMeter Downloads page) on next available opportunity
I have a problem with connecting to existing remote MSSQL database from inside of a docker container running in stack.
My application consists of three modules (backend, frontend and haproxy)
Backend module is written in Java (SpringBoot app) and it's also the one that needs to connect do remote MSSQL database (by remote I mean placed on different sever, separate of docker part).
I have the following docker compose file:
I start the stack by using following command:
docker stack deploy -c docker-compose.yml myapp
The result is, all containers are up and running, but spring app reports that connection to DB is timed out:
Server seems to be configured properly, I am able to access the host from container through telnet.
When running independently (even from docker container) backend app is able to connect to database with no problems, while stacked with docker-compose however it's unable to connect to the very same db.
I've also tried to provide db server IP instead of host name - no success.
Maybe setting up networks section in docker compose would do the trick?
UPDATE
Another thing you can do is to use host.docker.internal instead of the IP address of the database. This ONLY works on docker for windows or docker for mac.
Source: I want to connect from a container to a service on the host
OLD, only works when not in swarm mode
You need to specify that docker should use the same network as the host, you can do this in the following way:
version: '3'
services:
web-app:
build:
dockerfile: web-app/something
ports:
- 8080:8080
network_mode: "host"
Reference: Use host networking
It seems that the issue was caused by networks overlapping.
Adding network configured as show below, allowed either to connect to my remote database and keep my endpoints hidden:
networks:
backend:
ipam:
driver: default
config:
- subnet: 192.168.40.0/26
I have a docker swarm setup with services registered in an overlay network. Comunication between services is working fine however I get a "Connection refused" from one of my services that connects to an external DB. The service is a Java based application (spring boot).
The connection is defined with its IP (jdbc:mysql://192.168.130.141:3306/database?autoReconnect=true)
I have checked that I can ping the server from the container docker exec -it e093 ping 192.168.130.141 gives expected answer
I have rechecked (4 times) my credentials
I can connect to the DB from the host
Host is Ubuntu 16.04.4 LTS
I am running docker 18.03.0-ce and the exact error is
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_151]
I'll skip the full stack trace here.
Any help would be greatly appreciated
--EDIT--
Let me clarify that the database is a Galera cluster and the IP I try to connect to is the load balancer (HAProxy) in front of it. I know the setup works as I have other applications connecting to the cluster in this matter as well as the service itself (when not in a docker container).
So, as far as I can tell, my connection informations are correct but it doesn't connect from inside docker services.
Can you show your docker-compose.yml? In the ports you have to expose the port that you need to access.
ports:
- 3306:3306
You can install telnet to test if the port is open using this commands inside the container
docker container ls
docker exec -it conainerid bash
apt-get update
apt-get install telnet
So I have a clone of the java application, and an active couchbase database, everything on my local machine. When I run the java spring application, everything works well, the application will connect to the database.
On the other hand, I use the same project and database configurations using docker containers. But I can't seem to make them communicate, and when the app starts, I keep getting this exception:
java.net.ConnectException: Connection refused: localhost/127.0.0.1:8091
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at com.couchbase.client.deps.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:223)
at com.couchbase.client.deps.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:285)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:589)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:513)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:427)
at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:399)
at com.couchbase.client.deps.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at com.couchbase.client.deps.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
I also created a docker network where I put the app and database.
Any idea why there is no connectivity ?
you try to connect to container's localhost
java.net.ConnectException: Connection refused:
localhost/127.0.0.1:8091
But you need to connect to another container. If you run docker container with argument --link mysql:mysql you need to specify into app configuration file connect to mysql instead of localhost of 127.0.0.1
I new using spring boot and docker and I faced a problem running the docker containers.
On debug mode, there is no problem on applications boot, but when I run them as a container, there is something wrong.
For example, I have my server config with all the yml files, also eureka properties.
The config server boot perfectly, but not the eureka server, it must look for it`s configuration to the config server becouse of these:
uri: ${vcap.services.config-service.credentials.uri:http://127.0.0.1:8888}
In the eureka`s log I can found:
Could not locate PropertySource: I/O error on GET request for
"http://127.0.0.1:8888/server-eureka/default":Connection refused;
nested exception is java.net.ConnectException: Connection refused
So I see that eureka cant connect to the config server for a reason I cant understund.
Maybe I miss something in my docker file.
If you are not using docker linked containers you'll have to use only the public ip addresses. Docker will assign every running container an own ip address which is per default not accessible. Only when you start to expose ports there will be an entry to iptables that is linking the hosts public ip address and given port to the internal used port and (dynamically assigned) ip address of the docker container. This is also why 127.0.0.1 does not work cause it would look into the containers local context but tgere the service is not running.