NoRouteToHost Exception - java

I can SSH and PING a machine running Fedora 18, but whenever I try connect to it using Sockets, I get NoRouteToHostException (I tried Java and C++, and I get the same error).
Any ideas? I have looked around but could not find a solution that works.

If you're not trying to connect to the same port that ssh(1) uses (port 22) then the problem could be that a firewall exists between you and the destination and it doesn't allow your packets through. You can test this by having your code try to connect to port 22 on the destination host. If you don't get the same exception, then this is the likely cause.
You should also verify that your code is OK by having it try to connect to the local host (i.e., the computer on which it's running). You should not get the no-route-to-host exception (unless the firewall on the local host is doing something odd)

Related

Java RMI - Lookup Success , but method call fails - Onpremise Vs AWS

I have a java code which makes connection to a Java RMI server - lookup followed by method invocation.
Both machine are under the same firewall in onpremise and works as expected.
When my client/java moved to AWS, the RMI server is still running in on-premise.. But here in this case, it fails with below error..
Lookup success, method call failed..
Lookup for Remote Object Successful.
ErrorMessage:startupFunction : RemoteException Caught.. Connection refused to host: XXXXX ; nested exception is:
java.net.ConnectException: Connection timed out
PS : I see similiar issue in this post, but nothing seems to work in my case
You need to export your remote object on a fixed port, and open that port in your firewall.
Fixed this by adding the port used by RMI Method.. We ran the request from on-premise and in the RMI host we ran netstat and captured the port list.. This way we could figure out the port and enabled in Security group in AWS.. thanks all for your help..

Connecting to derby via I.P. Address fails

When I print the I.P. address of the system using InetAddress.getLocalHost(), I get user-VAIO/192.168.1.3 . Now, when I connect to derby using jdbc:derby://localhost:1527/mydatabase;create=true, it connects without any errors but when I connect the same using jdbc:derby://192.168.1.3:1527/mydatabase;create=true, it fails giving me the following exception:-
java.net.ConnectException : Error connecting to server 192.168.1.3 on port 1527 with message Connection refused: connect.
Any help will be appreciated.
When you start your Derby Network Server, you provide a value for the '-h' argument. You might not realize you are doing this, if you are using the packaged StartNetworkServer.bat file, but look inside the batch file, and you will see the -h argument there.
The batch file comes provided with the syntax '-h default' when you download Derby from the Apache website.
But you can change that, to say, for example, '-h 192.168.1.3', and then your Derby Network Server will accept connections that specify 'jdbc:derby://192.168.1.3/my/database'.
Note that if you want to accept such connections from other computers on the network, you will also have to adjust your Windows Firewall rules, as by default it will prevent such connections.

java and access error when connecting to the database

Today I encountered the following problem. When connecting to a database, the following error.Appeal to the remote database by connecting through vpn.
Added necessary firewall ports and even tried to disconnect its(did not help)
Added record to $JAVA_HOME/jre/lib/security/java.policy
grant codeBase "file:/-" {
permission java.security.AllPermission;
};(did not help)
If trying to connect with same data through sql management studio, it works and there is access. from the development environment no connection
Example(string connection = jdbc:sqlserver://DEVMSSQL14.test.com:1433;SCHEMA=test;DATABASENAME=test, sql managment studia = DEVMSSQL14.test.com,1433)
on another computer it works without problems, the same version of the project
It remains only to "Permission denied: connect".Maybe somebody faced with similar
Error:
The TCP/IP connection to the host DEVMSSQL14.test.com, port 1433 has failed. Error: "Permission denied: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
In the error message, you have shown like DEVMSSQL14.test.com, 1433 has failed.
I believe, it is correct. I dont think. this host name is correct. which says "TEST" as domain
Open the cmd, try to ping DEVMSSQL14.test.com
Success case :
If you are able to ping, then make sure the services are running for sql in services
Failure case:
Get the right host name to establish the connection
When i tried, i got this message, because i may be out of network.
Pinging DEVMSSQL14.test.com [208.64.121.161] with 32 bytes of data:
Request timed out.
Request timed out.
Try setting a System Property while running the code.
The catch is to introduce this line in code: System.setProperty("java.net.preferIPv4Stack", "true");
Or to pass it in VM option: -Djava.net.preferIPv4Stack=true

could not open connection to the host, on port 23: Connect failed

I have extremely simple chat server (100 lines of code on Java) and it is working properly. When I'm testing it with Telnet on localhost everything is just fine. When I asked some of my friends to test it with telnet (telnet <myIP> <port>, the port I assigned is 5555, server is running on my PC with static IP) everything is just fine too, but one of my friends received the error
Could not open connection to the host, on port 23: Connect failed
when he was trying to connect. Every firewall, anti-virus and anti-spyware software is turned off from both sides. Why could some of my friends connect but not him? Where is the problem: is it on the server or his PC?
I had a similar issue before and what it turns out to be is the syntax. When I do:
telnet 192.168.10.10:3333
I will get the port 23 error but if I type in:
telnet 192.168.10.10 3333
I will get correct result.
Try to make the telnet connection as
telnet 192.168.10.10 3333
without using :
Your friend's Telnet client is obviously attempting to connect to port 23, not 5555 or 43839, since that's what it says in the error message he is getting.
Ask your friend to check the documentation for the Telnet client he's using, and make sure he's specifying the port the proper way.

Java - trouble running basic socket networking program

I'm trying to implement Sun's example Socket program, i.e. the KnockKnock server and client found here: http://download.oracle.com/javase/tutorial/networking/sockets/readingWriting.html
So I build the 3 files (EchoClient, KnockKnockServer, KnockKnockProtocol) into a project, build them, then go to cmd to run them:
> java KnockKnockServer
> Could not listen on port: 4444.
Also, I have trouble with the EchoClient (not that it means much since the server doesn't work). I get the following:
> java EchoClient
> Couldn't get I/O for the connection to: localhost
The one thing I changed in EchoClient class was to try and connect to "localhost" instead of their example machine "taranis". I don't understand the I/O error at all though.
So I need to figure this stuff out so I can later adapt it. Here's what I'm wondering: how do I know what port listen for in the KK Server? And if I want to connect to another computer in the EchoClient, would I directly put their (IPv4) IP address instead of "localhost"?
Thank you for any help
Try a different (higher port) because 4444 might already be in use on your machine:
Technical description for port 4444:
The port 4444 is specifically assigned to the Kerberos 5 authentication features particularly the implementation of Kerberos 4 in various systems including those running under the Mac OS X platform. The communication port 4444 is used in the conversion of Kerberos 5 credentials into an acceptable Kerberos 4 format.
source
That tutorial breaks rule #2 about handling exceptions: it makes up its own error message ' Couldn't get I/O for the connection to: ...' instead of printing the actual exception. Change it to do that, then you have some hope of finding out what went wrong.
I complained about that tutorial about eight years ago ;-(
(Rule #1 is print something.)
I had this problem yesterday when I was trying to learn the same thing you are!
1) Make sure both the server and client have the same port for example:
kkSocket = new Socket("localhost", 802); //Client
serverSocket = new ServerSocket(802); //Server
(I ran into this problem by accident)
2) Try changing both the server's port and the clients' port to 10000 or higher
3)The program outputs "Knock! Knock!" and than you need to type the input.(The hang you described might just be the server waiting for an input)
try this:
change taranishost name to localhost
kkSocket = new Socket("localhost", 4444);

Categories

Resources