0

I have written a TCP client server pair using Java sockets. When I run both the client and server from my local machine, I have no issues. Again, if I run the server on my local machine and the client on an Ubuntu virtual machine (also on my local machine), nothing goes wrong. I get the below error when running the server on my local machine and the client on another. I thought it could something to do with the firewall so I shut it off on both machines but the issue persisted. Could it have something to do with the port I've selected? (I used a random port in the 4000's).

java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
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.PlainSocketImpl.connect(PlainSocketImpl.java:172)
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 client.Client.start(Client.java:150)
at client.Client.access$100(Client.java:20)
at client.Client$2.run(Client.java:129)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

1 Answer 1

2

No, it has nothing to do with the port. It is a connectivity issue between the two hosts. There isn't any. You won't be able to telnet to that IP:port either. You need to review your network topology.

Sign up to request clarification or add additional context in comments.

2 Comments

+1, but I would not say there isn't any connection from that error. There can be connection but firewall is preventing TCP handshake.On other hand, on "no connection", ICMP can immediately report that fact as "host unreachable" error (or similar) without waiting for timeout. But yes, in general it means that target machine didn't acknowleged TCP connection attempt in time period (for whatever reason).
@rkosegi The OP states he has disabled both firewalls. The fact that ICMP UNREACH exists as another way to prove lack of connectivity isn't relevant, as he isn't getting that message. Your logic is awry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.