Client can not connect zu Server - java

im trying to connect a client to a server. The server is running, but when i try to connect the client i get this error:
"Exp_Client cannot connect to Exp_Server. Connection refused to host: 127.0.0.1.; nested exception is: java.net.ConnectException: Connection refused"
the method which should connect; the marked line does not work
the relevant constants
I turned off the firewall
VM-Options are:
-Djava.security.manager
-Djava.security.policy=/Users/Max/Documents/Uni/Bachelor/Vertiefung/Bachelorarbeit/workspace/kit-iism-experimenttool/Exp_Implementation/java.policy
Program arguments: none
I use IntelliJ IDEA 14.1.5
JRE: 1.60_65
jdk1.7.0_79
JVM: Java HotSpot(TM) 64-Bit Server VM
h2-1.3.176
Any ideas what the problem could be?
Would be very thankful for help.
Kind regards, Max

Just a few ideas:
You have not started your server correctly.
You are trying to connect to the wrong port.
Your server is not waiting to accept connections.
Your source code would be great to have a look on

You haven't started the RMI registry, or the URL isn't correct.

Related

Yet another MySQL connection issue

I have to deploy my java server app to a Debian 8 server. It tries to connect to the MySQL server via unix domain socket or tcp (depending on connection string). It works fine on my Debian 9 development server, but gives (as i think) useless error messages on the live server. I have root access to both servers but not allowed to do much on the live server. As i had version troubles compiling java on D9 and running it on D8, i have installed openjdk-7-jdk and mysql java connector on the D8 from the Debian repo, copied (symlinked) the connector jar to the lib directory of the source, and recompiled the app. Now it starts but when trying to connect to the database, it throws the following errors:
TCP: Connection refused
UDS: File not found (nonexistent file or device) ((the translation may not be correct, sorry))
Both connections (TCP and UDS) works fine from PHP & PDO.
Connection strings:
TCP: jdbc:mysql://localhost/<dbname>?user=<user>&password=<pwd>&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=utf8
UDS: jdbc:mysql:///<dbname>?socketFactory=com.mysql.jdbc.NamedPipeSocketFactory&namedPipePath=/var/run/mysqld/mysqld.sock&user=<user>&password=<pwd>&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=utf8
dbname, user, pwd and the socket file path are copied and pasted from the working PHP code. Worth noting that i'm not a java expert, i may not know something that should be known using these older libraries. Some source code:
Class.forName("java.sql.Driver");
...
Connection db = DriverManager.getConnection(Settings.sqlConnection.value);
try(Statement stmt = c.createStatement())
{
stmt.execute("SET #now = UTC_TIMESTAMP()");
}
...
Version info:
Debian 8.7
MySQL server 5.5.53-0+deb8u1
java version "1.7.0_181"
OpenJDK Runtime Environment (IcedTea 2.6.14) (7u181-2.6.14-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.181-b01, mixed mode)
mysql-connector-java-5.1.42.jar
What am i missing? Why do i get connection refused and missing file error messages while clearly the server is listening and the socket file is there and have the right permissions - and other clients can connect?
Nevermind, i've got the solution (not much after posting the question and so much after started having the issue... as usual).
UDS: I simply mixed up named pipes with unix domain sockets which are two entirely different implementations of the same concept. JDBC simply can't do UDS. Now i realize that i tested my code on the dev server probably with TCP connection only.
TCP: The server socket was bound to the server's exact address therefore localhost wouldn't work. My narrow thinking about connection refused error completely misguided me.

How to connect to a Grakn Server running on a GCP VM instance

I'm trying to connect to a Grakn Server running on a GCP VM instance. I have read the related post in the discussion forum. One of the replies suggests to do the following on the server side:
Edit ./conf/main/grakn.properties:
storage.hostname=EXTERNAL.ip.v4.address
Edit ./conf/cassandra/cassandra.yaml:
seeds: "EXTERNAL.ip.v4.address"
broadcast_address: EXTERNAL.ip.v4.address
listen_address: INTERNAL.ip.v4.address
rpc_address: INTERNAL.ip.v4.address
Access it from the Java API:
GraknSession session = Grakn.session(“EXTERNAL.ip.v4.address”, keySpaceName);
What i have interpreted from this, for my specific case, is the following:
-Replace EXTERNAL.ip.v4.address with the External IP of my VM instance
-Replace INTERNAL.ip.v4.address with the Internal IP of my VM instance
When i start the server i get this exception cause (I think this is the root cause):
Caused by:
com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException:
PoolTimeoutException: [host=104.197.131.17(104.197.131.17):9160,
latency=10000(10000), attempts=1]Timed out waiting for connection
at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:231)
What am i missing?
Do i have to add firewall rules?
Thanks for the help.
To access Grakn remotely using the Java API, you need to open the following ports on the GCP and Linux VM firewall (eg. iptables):
4567
9160
Make sure you are able to access those from the client machine.

Remote debugging from eclipse

I am trying to remote a debug an application which is deployed through Websphere. I have all the port configured correctly on server side and on eclipse side. I can use
telnet host port
to connect to remote host and port correctly. But When I try to connect through remote debug through eclipse, I run into the error
Failed to connect to remote VM
com.sun.jdi.connect.spi.ClosedConnectionException
What can be the possible causes for this? I have checked and searched Stackoverflow for this error already. I have tried the most things from answer on this question Eclipse Error: "Failed to connect to remote VM"
I changed the port and it worked. It was a networking issue with that port of 7777.

Java Mission Control: Flight Recorder throws: javax.naming.ServiceUnavailableException

I am trying to profile a Java Spring application with the Oracle Java Mission control.
I have the JVM Connection configured as: localhost:7091
and I started the application with java -Dcom.sun.management.jmxremote.rmi.port=7091 -jar app.jar.
When I attempt to start the flight recorder I get an error message.
Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
Could not connect to a JVM at service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi. Make sure one is running and that you are using the correct protocol in the Service URL.
Does anyone know what could be the reason for that error?
You could try to use auto discovery. Then the connection will show up automatically in JMC
-Dcom.sun.management.jmxremote.autodiscovery=true
You can also name the connection so you can identify it easily.
-Dcom.sun.management.jdp.name=App
and disable security
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
I had this issue. I had installed JDK 10 on Windows Server 2016. With JMC and the JVM I wished to monitor on the same server.
When going live, we switched the IP from a temporary IP to a live IP. However, JMC resolved localhost to the original IP. Also when specifying the server's current IP, JMC resolved it to the original IP.
Adding -Djava.rmi.server.hostname=localhost to the Java process I wanted to monitor, resolved the issue.
However, I will would still be interested to know why JMC (or RMI) still resolves incorrectly.

connecting to postgreSQL server failed

I am trying to install "Kwok information server" and I am new to postgreSQL. I just followed the installation guide of Kwok information server.
when I am trying to install kwok-schema-setup.jar file using java through postgreSQL server in Command Prompt, I am getting the following error..."Connecting to PostgreSQL Server ...failed. Connection refused. Check that the ho
stname and port are correct and that the postmaster is accepting TCP/IP connecti
ons. Cause: java.net.ConnectException: Connection refused: connect
Schema setup encountered errors" .
And when I am trying to connect to the server using pgAdmin III, I am getting the following error "Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? ".
Please anyone help me regarding, Thanks in advance!!
Looks like your Postgresql daemon is not running. Check if the server has started and is running. I dont know which OS you are using but try ps -ax on linux/mac or the task manager in windows.
Maybe a firewall that is blocking the connection, you have to provide more information about your environment to be sure.

Categories