OWASP Dependency Tracker Jenkins Plugin - Connection Refused - jenkins

I have installed the Dependency tracker plugin in Jenkins but when I'm trying to configure it and test the connection, it is giving an error, and an error message is also not clear to me.
error message:
Connection failed
java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
Please help me resolve this issue.

Is both Jenkins and Dependency-Track running as a container?
If so, setting the Dependency-Track URL to http://localhost:9090 will result in Jenkins attempting to connect to port 9090 on its local container.
You can try setting the Dependency-Track URL to use the IP address of the docker network interface. (e.g. http://172.17.0.1:9090)
See https://www.baeldung.com/linux/docker-connecting-containers-to-host.

Related

Run testcontainer test OK in local environment but failed in jenkins

Background
In my application, it needs to connect to zookeeper to get some useful information. So I start a zookeeper container in my integration test with port binding like -p 2859:2181.
zookeeper = new GenericContainer<>("zookeeper:3.6.1")
.withEnv("ZOOKEEPER_CLIENT_PORT", "2181")
.withExposedPorts(2181);
zookeeper.setPortBindings(Arrays.asList("2859:2181"));
zookeeper.start();
Then I use the following command to run the test. It goes smoothly connecting to localhost:2859 without any problems.
mvn -Dtest=xxxIntegrationTest.java test
Problem
However, when I use jenkins to run the same test with same command, it cannot connect to localhost:2859, complaining that
2020-10-28 12:16:04.282 INFO [main-SendThread(localhost:2859)] Opening socket connection to server localhost/127.0.0.1:2859. Will not attempt to authenticate using SASL (unknown error)
2020-10-28 12:16:04.283 WARN [main-SendThread(localhost:2859)] Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
I don't know why it behaves differently in these two senarios. Could anyone give me some suggestions?

guacamole not able to connect neither VNC nor RDP

I setup a guacamole server on ubuntu 16.04 Tried to setup a connection to a vnc server on the same machine and always got errors. I tried with RealVNC Xvnc11 TIghtVNC, and even with RDP. no luck. The error messages on log files were:
Creation of WebSocket tunnel to guacd failed: Non-numeric character in element length.
Creation of WebSocket tunnel to guacd failed: java.net.ConnectException:
Connection refused (Connection refused)
An internal error has occurred within the Guacamole server
not a valid RFB client
webSocketsHandshake: invalid client header
Any idea what could be?
The problem was that I was saving the VNC connections settings on the GUACAMOLE PROXY PARAMETERS (GUACD). I set port 5901. Which is not the correct guacd port.
I left this empty and everything worked!
for RDP use RDP encryption select option
it worked for me.

Spring AMQP unable to connect back to RabbitMQ server after rabbitMQ server is restarted

Our application is able to connect to RabbitMQ server, messages get received in the message listeners, everything works fine. But when RabbitMQ is restarted then, we get below exception in the logs and messages are not received in the listeners. Once we restart our application container as well, then everything starts working. We cannot restart our application in Prodcution environment and we want the application to be able to recover connection to RabbitMQ once RabbitMQ server is up. Can someone please help.
2018-05-10 09:10:01,561[SimpleAsyncTaskExecutor-34]|DEBUG|org.springframework.beans.factory.support.DefaultListableBeanFactory|13-org.springframework.beans-3.1.4.RELEASE|Returning cached instance of singleton bean 'org.springframework.amqp.core.Queue#3'
2018-05-10 09:10:01,560[SimpleAsyncTaskExecutor-27]|DEBUG|org.springframework.amqp.rabbit.listener.BlockingQueueConsumer|435-wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar-0.0.0|Closing Rabbit Channel: null
2018-05-10 09:10:01,563[SimpleAsyncTaskExecutor-34]|DEBUG|org.springframework.amqp.rabbit.listener.BlockingQueueConsumer|435-wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar-0.0.0|Starting consumer Consumer: tags=[[]], channel=null, acknowledgeMode=MANUAL local queue size=0
2018-05-10 09:10:01,560[SimpleAsyncTaskExecutor-32]|DEBUG|org.springframework.beans.factory.support.DefaultListableBeanFactory|13-org.springframework.beans-3.1.4.RELEASE|Returning cached instance of singleton bean 'org.springframework.amqp.core.Queue#1'
2018-05-10 09:10:01,559[SimpleAsyncTaskExecutor-29]|WARN|org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer|435-wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar-0.0.0|Consumer raised exception, processing can restart if the connection factory supports it
org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:54)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:195)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:371)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:80)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:130)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:67)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:365)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1009)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_80]
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.7.0_80]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)[:1.7.0_80]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)[:1.7.0_80]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)[:1.7.0_80]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.7.0_80]
at java.net.Socket.connect(Socket.java:579)[:1.7.0_80]
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:625)[:1.7.0_80]
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:50)[432:com.rabbitmq.client:4.3.0]
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:61)[432:com.rabbitmq.client:4.3.0]
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:99)[432:com.rabbitmq.client:4.3.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:925)[432:com.rabbitmq.client:4.3.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:884)[432:com.rabbitmq.client:4.3.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:842)[432:com.rabbitmq.client:4.3.0]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1026)[432:com.rabbitmq.client:4.3.0]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:191)[435:wrap_file_._jetstream_thirdparty_spring-rabbit-1.3.6.RELEASE.jar:0]
... 7 more
This exception seems wierd to me because, if RabbitMQ is refusing connections then, how is the connection established when we do an application restart.
This issue is giving me a very hard time.
The 1.3.6 is too old and out of support version. Would be great if you consider to upgrade to the latest one: https://projects.spring.io/spring-amqp/, at least 1.7.7 . Also read this: https://docs.spring.io/spring-amqp/docs/2.0.3.RELEASE/reference/html/_reference.html#auto-recovery.

connection failed for: localhost (Errno::ECONNREFUSED: Connection refused - connect(2))

I am using capistrano 2.15.5 for my rails application deployment. I am using localhost for server and have also tried with 127.0.0.1 in place of localhost. After running *cap production deploy:setup* the error that i am getting is: **Errno::ECONNREFUSED: Connection refused - connect(2)**.
After searching for it i found out ECONNREFUSED means the client couldn't make a TCP connection to the server, either because it's down, or its DNS is not resolving..
how to fix this issue?
thanks.
You have to add your ssh key in server's ssh authorize keys

Connecting slave to a jenkins master

I tried to connect slave to jenkins master through java web start but my efforts failed in the end.
I executed java -jar (jar file) (url) to connect and got the following errors.
java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at hudson.remoting.Engine.connect(Engine.java:321)
at hudson.remoting.Engine.run(Engine.java:210)
Please help. Both Master and Slave use Ubuntu Linux.
First of all, SO is not bug tracker for Jenkins project nor developers.
The Jenkins JIRA is located here: https://issues.jenkins-ci.org/secure/Dashboard.jspa
Secondly, in the wiki pages:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service
https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds
contains pretty sufficient information that might guide you to fix. Probobly not permanent, but at least temporary.
For your comfort, here is the first link that fits the stack trace:
Check that the JNLP port is opened if you are using a firewall on your server. You can configure its value in Jenkins configuration. By default it is set to use a random port.
Cheers and good luck!

Resources