Problems with router configuration for sever client - java

I'm working on a java project for some time now, the project contain a server and a program that connect to the server.
until 2 weeks ago, every thing worked fine, i could connect to the server from my own network ( that run the server) and from other network (WAN) as well.
2 weeks ago i provider network and got a different router from them, so as i did before i entered its settings and
opened the port for my program ( with port forwarding and all this..) how ever, it doesn't work well as it was before.
if I'm using the ip (from whatsMyIp) and put it in the client, i can enter to the server from other networks how ever I cant enter to it from my own computer that run the server.
if I'm using the ip (from ipconfig), i can enter the server from my own computer however other networks cant connect to
my server.
(as i told before, all worked fine before i changed my router)
hope you can help me.. thanks

If you can access the server from outside your network using your public IP but not from a computer in your local network (using the same public IP) then check your router settings (firewall or port forwarding). There's probably a setting there allowing port forwarding only from your public interface and not from your private int.

Related

Client-Server Chat application JAVA

I have a simple java written client and server chat application(with sockets). When running on the same network/computer it works fine. However when i try to run the client from a different network it doesn't connect. I tried using the public IP address of the server to connect the client to the server but without luck. How would I be able to connect to the server app from a different network? any help would be appreciated.
It sounds like you have more of a firewall issue than a problem with the application. Instead of trying to connect with the Java client, first try connecting with Telnet to the server from the same computer, then from the other computer. The first effort will show you what to expect when it works. For instance, if your server is running on port 999, use telnet server.example.com 999.
If the machines are Linux boxes, use iptables -L to see whether there is a block on the port you are trying to access.
If you're still having problems reaching the server, run tcpdump -i tcp:999 on the server host to see what traffic is making it to your server socket, then run the telnet commands again. You should see the tcp connection established when connecting from the local machine, maybe or maybe not when connecting from other machines. If you don't see it while connecting from other machines, run tcpdump there too to make sure the client is definitely sending the traffic to the server.
After you are sure that the server can receive traffic and that your client is sending the traffic, there are no mysteries about what is actually going on and you should find your problem.
It worked after I did port forwarding on router. Most of the ISP provided modem/routers wont let you manipulate ports so had to buy my own modem/router, forwarded the port and worked like a charm. Information on what port forwarding is can be found here : http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/

can an isp block incoming connections?

First of all, i am a newbie in network programming. Few days ago, i wanted to test a simple java server(simple java echo server). I first tried running it in a university computer and then tried connecting through my laptop which is in a different network without any success. I assumed the network(private university network) didn't allow the connection. Next, i ran the server in my laptop expecting it to be public. I ran the server. I ran it in port 5000. Since the connection was through wifi i also did port forwarding so that my router would know where to forward the incoming requests. I even disabled the firewall just to test. Then there is a tool in the internet which i obtained from some other user in stackoverflow http://www.yougetsignal.com/tools/open-ports/ which can check if a port is open in a machine. I put my ipaddress and port number to see if it is reachable. It continued saying the port is closed. Although i don't have a good idea about networks, i called the ISP and asked if the issue was with the network being a private network and if it is possible to host server in my laptop, she concurred saying it was private network and what i am trying to do is not possible. I wanted to try it in some other computer. I met one good guy in stackoverflow who allowed me to run the server in his computer in taiwan. He disabled his firewall or added an exception, then ran the server. I then ran my client and it could successfully connect to his server. I was ecstatic.
So, my question and curiosity is how does isp blocking incoming connection work? Did the ISP really block the incoming connection to my server or could the problem be with some other things? Is it ever possible to host server in my laptop which is accessible to the world. I am still not content with the answer i got from the ISP which was it was private network so it was blocking..isn't internet basically the collection of private networks connected to each other so isn't everyone in one way or other part of a private network? Please help me with these dilemmas. Appreciate your effort and help a lot! :)
Your house probably has one global external IP assigned to you by your ISP. They will normally block commonly used ports incoming, such as 80 (HTTP), 22 (SSH), 23 (Telnet), 25 (SMTP), and 443 (HTTPS). The majority of the remaining ports should be open for you to use.
As you have one global IP, and multiple devices on your network, you need to tell your router which computer the incoming traffic on a given port needs to go to. This is called Port Forwarding. As you don't control the routers upstream from you at your university, you can't change anything while there. At home you can.
Port Forwarding is explained in depth here.
I suppose it depends on the ISP. I have been able to open ports before with mine, using port forwarding from my router.
As a technician who works for an ISP, I can also say that the tech support generally doesn't have a clue whenbit comes to port blocking or networking in general, they mostly follow a script and ask you if you have turned it off and on again. Maybe check that you are forwarding the port correctly?

connect to local, public mysql server

Ok, long story short. I have a local mysql server setup atm via wamp. I have it set to online. When I run my program via eclipse, and JDBC set to localhot, it works just fine, but if I set it to use my external IP, it won't connect. I have checked the ports, and scanned them as well, they come back as mysql server listening on port 3306. I think I ran into a problem like this several years ago, something about it being a loopback issue, how can I get around this? At the very least, how can I be sure that the db is public and running ok if I can't force my local system to connect with the external IP?
Try to do telnet on your public server ip port.
telnet yourpublicserverip sqlport
If it succeeds then your ip-port combination is available from outside. If it does not then most likely it will be a firewall issue and you may have to open your firewall to allow incoming connections on your sqlport.

Use local pc as a server

I just made a little chat programm with a server and a client in java. The client needs to connect to the server with the ip of the server. All my testing I did with the localhost (127.0.0.1) and everything went fine, but when I tested it later on with a friend of mine, I had to notice that if I put my ip address (I run the server, he runs the client) that it doesn't work.
Is there a way to set up a private little server on my pc to run my server on, or maybe another way to get it working?
EDIT:
Just found a tool called "Apache" to set up your own server, could that might be helpful?
EDIT: When I say it doesnt work I mean I get an IOException, because this fails:
public void connectToServer() throws IOException{
showMessage("Attemption to connect...");
connection = new Socket(InetAddress.getByName(serverIP), 6789);
showMessage("\nConnected to: " + connection.getInetAddress().getHostName());
}
There is a whole host of things that you need to look at before your application will work.
Firewalls on both ends (and anti-virus applications) need to allow
the programs to communicate
Your ISP needs to allow messages to be sent via your designated ports
Your router (and the clients) need to not-filter these messages.
As a start, see if you can ping each others IP addresses and take it from there.
I recommend you first try and disable your firewall. If you are using windows, here is the instruction for turning off windows firewall: Turn Windows Firewall on or off
If you are testing with someone outside of your local network, you may need to setup NAT on the router of the person hosting the server. You can access the router by typing in it's local IP address in the web browser. This is usually something like 192.168.1.1 or 192.168.1.254 but it will depend on the model and network setup.
Once you have connected you should find an option (usually under advanced) for "NAT" or "Port Forwarding". I suggest you do a google search with the router model and how to setup port forwarding.
You also need to be aware that some ISPs will block certain ports. I suggest testing on a common port such as port 80 (HTTP) since it's unlikely an ISP will block this (be aware that you will need to disable Skype or any local web servers to test this)

Java program without forward port in router

I made application with java using socket. My computer is the server and my phone(android ) is the client. Only what i trying to do is to forward String from phone to client PC.
Everything works fine when i configure my router and open the port i using. i don't want every time when costumer will install my application will need to open port in the router.
I thought about using remote server that will run my server code. but i didn't find server that can do that . i don't want to make my pc a server for all costumers.
How does all the chats companies do it without open port?
You must look into UPnP. This is what /most/ if not /all/ torrent clients use to allow foreign connections, without forwarding ports. How chat clients do it is a different scenario. They use hacks such as firewall hole-punching using UDP (with an external server) http://www.h-online.com/security/features/How-Skype-Co-get-round-firewalls-747197.html see this link for details on UDP hole punching.
Also see this article http://www.codeproject.com/Articles/13285/Using-UPnP-for-Programmatic-Port-Forwardings-and-N for usage of UPnP. But this is in C++, but I think you will understand.
EDIT: http://4thline.org/projects/cling/ I found this. I think it can help you.
You had to open port probably because of your routers firewall :). If you already opened let us say port 9090 then every client app (android phone) will be able to connect to it :). Of course if somebody wants to install server on their own pc they would problably forward some ports and disable some firewalls. If you want server with no special requriements lookup VPS'es. :)

Categories