Java Connection - java

I have this server/client TCP. The server is run off my desktop. And the client is an applet over at http://example.com/new/ (You won't get to it because it will not load...) It WILL load for me but not anyone else.
The port is 24556 and the host is localhost but I DID portforward the port on my linksys admin page so people SHOULD connect. It works for me (obviously) because the server prints out the movement I go... but the applet won't even load for anyone else.... what's the deal?

Is the applet connecting to localhost or to the ip of your router?

I got the applet to load. Not sure why...I can't move around though.
This might have something to do with self signed content. And browsers defaulting to not let users run things. I know I've run into that problem before.
Is your computer set up with a static ip? Make sure the router points to that computer, or it'll never connect.
I wrote up a chat client in Java, see it here: http://code.google.com/p/phroxchat, feel free to use it to check if your port forwarding is setup properly.

Related

Can i host my ServerSocket or Java file somewhere on the web?

Heyy guys. I'm writing a chat application in java, works pretty well. But can i somehow host my Server file or the Serversocket on the web? I want to make it so my friends from other pcs can use the client and connect to the server file which is hosted on the web. Is that possible? Can i host the File/socket online?
When you run a java application that opens a ServerSocket, it opens a port on your local machine and starts listening for incoming connections. What you do with those connections is up to the implementation of the java code that you write.
The "web" is much less foreign than you are making it out to be. Your own computer can be on the web that you're talking about and people can connect to your chat service. Or you can choose to host it on something like an AWS server.
The following approach is assuming you are behind a pretty standard NAT config.
Once you run your java application, you need to make sure other computers can see you, either inside your LAN or outside on the internet. You want to start testing from as close to your computer as possible, then start expanding outward.
First you need to make sure that your computer's firewall is actually allowing connections on the port that your java application is listening on.
Opening ports in the Windows Firewall
Setting up and opening ports in Linux
Now computers on your LAN will be able to connect to your java program. Now you need to go one layer out, and port forward your router. This is much less standard so I can't help you too much, but Google can.
At this point, anyone on this internet, knowing your external ip and what port your java application is listening, can connect to your service.
If you chose to host this on an third party hosting service, you'll need to go through similar steps, but there may be slight differences that you can either ask about, or again Google is a great resource.

Can TCP/IP Server Accept a Connection Which is Being Forwarded by the ROunter

I have a fixed IP connection.
I am working on a project which will allow users to connect with my computer using a TCP/IP connection.
I am currently setting up the server on my machine (192.168.1.2) with port 69795.
My question is, if I forward all the requests made for the port to my machine, will the users be able to contact with the server?
I am sorry if my question is not clear.
It depends, but generally the answer is yes.
The things that might make the answer change from yes to no that you can influence:
Your server doesn't have a program ready to accept the connection on the correct port on 192.168.1.2
Your server has a firewall that discards the packets (parts of the connection) on the desired port on 192.168.1.2
The router is not configured to allow packets from the public networks to route to your server
The server doesn't know how to send the reply packets back to the router.
The server's program that responds is misconfigured or misbehaving.
There are also elements that you cannot control (but they thankfully are not often problems)
Someone else's router is misconfigured.
Someone else's computer is running a restrictive or misconfigured firewall or proxy.
Someone else has a client that is misconfigured or malfunctioning.
I suggest if you look into the Ciso CENT certification learning materials to get the basics of networking if you care to understand how some of this stuff works; but, you can easily configure your system to work without such understanding. If your setup misbehaves, often you can even fix it without full understanding. However, a good understanding of the details help greatly when something goes wrong.

Java router port setup programmatically

I'm wondering if there is a way to setup connection between a client and a server over the internet and have both of them programmatic setup all needed router/firewall configuration changes to open needed external ports to communicate.
Assuming both server and client have known ip addresses and a DNS is not needed in this example to find the IP addresses. How might one have a server that when started configures access past the firewall and tells the router how to route proper communication to the server. I would assume the client may not need anything like this as it should only need to know the external IP address and port number of the server. If i'm wrong about my assumption please let me know.
Example if I have two houses house (A) has a server and house (B) has a client and both sites know what the other house external IP address is and know what port they will be using how may a Java application do all the configuration or at least do as much as possible on say windows,mac,ubuntu. The idea is the user of the server and client should not have to do a bunch of firewall/router configurations to get the application running. It would also be nice if in the example it shows how to release the connections when the server is terminated. Example when the java server is turned off it should close up port settings on the firewall and router. security and clean house.
There is no easy way of doing that as it will depend on the OS and on the many possible firewall application running on the machine. Plus, if your app crash, you will never set back the original parameters, which can be problematic when talking about security. Instead of trying to set up custom configuration, you should try to use standard communication template/protocol like http. This will gives you a high probability of your app running without additional configuration almost anywhere (since there is almost no point of having an internet connection if you don't allow http port).

Failed port-forward for my diy application in Openshift

I have a java application with a server socket, but i don't know how to connect with another java web application in openshift. Looking in forums i saw i had to do port-forward to see wich ports i had to use in the connection between the web application(client) and the java application(server). But i have this error:
http://postimg.org/image/gjrrs80lp/
I did ssh -N 536(..) too, but it didn't work. I'm full blocked, i've never worked with sockets and ports and i'm blocked.
Thanks for the help guys ;)
You might do better to read up on sockets and ports then. Can you give a specific error that you are getting? If you are trying to use a non-supported port, then it will be blocked. If you want to do port forwarding between gears then you need to make sure you have a public/private key setup on your gears for that purpose and added to your account.

Can I be sure my Java web app running on localhost:8080 is invisible from my fellow Starbucks customers?

I'm developing a Spring application on my Windows 7 machine and running it on localhost:8080.
Is there any chance that if I do this in a public location like Starbucks that it is possible for my app to be visible to others?
(I'm using Windows Firewall and Microsoft Security Essentials)
Be sure that it is binding to localhost:8080 (i.e., 127.0.0.1), not all interfaces (which is probably the default). Server programs usually have an option to say which IP addresses to bind. For example, in Apache, you can provide an IP address to the Listen directive in addition to a port number. If you only bind to 127.0.0.1, the port will not be open for people scanning your external IP address.
Short answer: No.
Long answer: Someone might access your app like this:
If you visit a malicious website (if anyone at Starbucks is poisoning the DNS cache or spoofing DNS responses then you may visit a malicious website at www.google.com not knowing about it) then the attacker may send you to his domain with a DNS server (which may in fact be on his laptop) replying to the same query with very short TTL once with his IP, then with 127.0.0.1, then his IP again, etc. That way when you are sent to (http://www.example.com:8080) it is resolved as the attacker's IP and you get the website which starts an AJAX request to the same domain and the same port (so the same origin policy is satisfied in every browser) but thanks to the short TTL you don't have the domain entry in your cache any more, so you ask again and this time you get the answer 127.0.0.1 which incidentally is your own loopback interface which you assume to be invisible from the outside - and it is in fact invisible from the outside but perfectly visible from your browser. Your browser will happily connect to your app at 127.0.0.1:8080 and proxy the request to the attacker with another AJAX connection or any other side channel. VoilĂ , your app is now connected to the world!
Things like this happen in the wild so be careful. Sometimes people even access admin interfaces in routers behind NAT and firewalls that way. Quite frankly I'm pretty scared by all of the responses telling you that it is impossible to access anything running on localhost. Be careful what you do.
Is there any chance that if I do this in a public location like Starbucks that it is possible for my app to be visible to others?
Of course! People can look over your shoulder.
what Jeremiah said. use netstat -an to check what addresses it bound to.
and never trust Windows firewall, or any other software to which you don't have the source.
If the port is open it can be. If you program it to only accept connections from localhost while developing then even if they can see it, they wont be able to connect to it.

Categories

Resources