Java TCP Client Server working over LAN with port Forwarding but not with hamachi

1.2k views Asked by At

I have a basic Java Client Server TCP Programm which is able to connect over LAN and also when i use my public ip with port forwarding.

What bothers me, is that it does not work when i try to use the same programm inside of a hamachi VPN network. I want to get it to work there as well, as many people try to avoid port forwarding but use hamachi as it seems easier for them.

Server Code ss = new ServerSocket(4444); Client c = ss.accept();

Client Code Socket client = new Socket(, 4444); printWriter = new PrintWriter( new OutputStreamWriter( client.getOutputStream()));

I googled and could not find any information about this problem, as usual people ask how to avoid port forwarding and are told to use hamachi for example or learn how to forward their ports.

Thanks in advance!

2

There are 2 answers

0
Kevin Streicher On BEST ANSWER

The error was another part of the program did close some of the streams and as in java closing one encapsulated stream closes everything beneath it.

0
Anssssss On

Could hamachi actually be blocking a port? I like to use ncat and nmap to test for these things.

"ncat -l portNumber" will start a server listening on portNumber

"nmap -Pn -p1234 someHost" will see if port 1234 is open on someHost (without doing a ping to determine if the host is up first)

Setup the above with your server and client, try it for your port 4444 and try it with some ports that nobody blocks like 80 or 443. If it works for those normal ports, but not for 4444, then something (hamachi?) is blocking that port.