port forwading to make a server on my computer

0

I tried to make a chat program with java. i succeed when i use the ip of 127.0.0.1 to connect.

Socket socket = new Socket("127.0.0.1",5005);

it all worked great on my computer and the program even worked when i try to connect between my comupter and my leptop which uses the same router. (i did it by using the local ip.) Then i wanted to connect computers which uses other routers by using the external ip. so i read on web and i understand that i need to forwad my port through my router. i have a Siemens ADSL Sl2-141 router. i forwad the port 5005, and my chat program still doesn't work. i get Connection Refused error over and over. did i missed somthing? Siemens port forwading

Shelef

Posted 2013-02-11T16:59:47.593

Reputation: 1

double check Internal Host IP-address. Did you try both your laptop and your desktop computer as target?. Do you use any further (software)-Firewalls? – yankee – 2013-02-11T17:03:36.857

NOTE: Although this question has been migrated I don't think it is clear if this is a network configuration issue or a code issue (listener/connection going through correct IP addresses). Until we get more information it may be a case of hasty moderation. – Grambot – 2013-02-11T19:22:08.403

Answers

1

First, it seems you're configuring your code to listen on the localhost only and not external address. Use a socket connection like this instead: (as per this guide)

EDIT (Changed as per comment discussion below):

Socket socket = new Socket("PUBLIC_IP_ADDR",5005);

Where PUBLIC_IP_ADDR is your internet facing address that you can locate here

If you still can't get a connection verify the program is available and listening...

Guide to checking your port

1) If you haven't already, go through this guide and confirm you've done all the steps.

2) Use this tool to confirm your port is actually open.

If #2 fails then your port is not actually open. Does the PC that accepts the connection actively listen on 5005?

Windows:

Start -> Run -> cmd
  netstat -an | find /i "5005"

Linux:

(From terminal)
  netstat -l | grep 5005

If that doesn't have "LISTENING" listed beside it then your application is not listening for connections. But I don't suspect this to be the problem since you can do it on localhost.

If that fails then confirm your OS firewall is open.

That's about all I can think of right now

Grambot

Posted 2013-02-11T16:59:47.593

Reputation: 227

the code above is for the client file. in the server i used the code you gave. the tool you gave give me positive answer: Success: I can see your service on 77.126.189.65 on port (5005) Your ISP is not blocking port 5005

i also tried through the cmd to check. this was part of the answer: TCP 0.0.0.0:5005 0.0.0.0.0 LISTENING the 0.0.0.0.0 mybe mean somthing? – None – 2013-02-11T17:39:58.700

0.0.0.0 Simply means its listening on all IPs (I believe). If you have the client file attempting to access a service on port 5005 of 127.0.0.1 it will attempt to find your server on the same computer you're connecting from. Change that to your public IP address. I'll update the answer with details. – Grambot – 2013-02-11T17:42:16.197

Sorry, do you mean you were able to connect? Or are you still unable to? EDIT: Also, since you are opening your service publicly I would suggest hiding the IP for the meantime in case anonymous people stumble on this page and start attempting to connect to you. – Grambot – 2013-02-11T18:05:07.360

i able to connect when i use 127.0.0.1. i cannot connect when i use my external ip for connection – None – 2013-02-11T18:32:23.563

Can you edit your question to include the code you set up the socket listener with as well? – Grambot – 2013-02-11T18:35:38.303

0

What @Brian said. Your internal address is probably wrong, if the program isn't running. Try replacing "127.0.0.1" with the internal ("10.whatever") address and then still run it from the same computer. If that works, only then should you try it from another computer. If it's blocked from another computer on the same subnet, then it's likely you have a software firewall ("Windows Defender" or some such) that's blocking external connections.

The problem of scope still remains: if you need help configuring your router, Google and then superuser.com are the places to ask. If you need help with programming, that's what this site is for.

Ti Strga

Posted 2013-02-11T16:59:47.593

Reputation: 101

i did succeed run the program by using internal ip(10.0.0.3 instead of 127.0.0.1). now im trying run the program by external ip – None – 2013-02-11T17:18:01.610