Results 1 to 2 of 2
  1. #1
    warwolf is offline Member
    Join Date
    May 2011
    Rep Power

    Unhappy Cannot connect to Java HTTP Server from external client

    Hi, I'm creating a personal tool that serves files through HTTP in Java. For the HTTP Server part I'm using the package. When I connect from my own PC using either localhost or the external hostname, it works, but when I try to connect from an external client to it, it just doesn't. I'd also like to mention that the java default policies file hasn't ever been modified and that I'm behind a router, and that the port is properly forwarded. I tried modifying the policies file but I didn't have any success, although I don't know if the settings were correct or if they got applied, and I read a thread in which there was a similar problem, but using rmi which has been solved by setting the java.rmi.server.hostname system property, but I don't think this is also available in my case because the server uses TCP.
    I also tried disabling the firewall, but still no luck.

    Just so this is clear. The client is any browser, so there shouldn't be any problems there.
    Here's the code that initializes the server:

    Java Code:
    Settings settings = Controller.getInstance().getModel().getSettings();
                int port = settings.getHTTP_PORT();
                server = HttpServer.create(new InetSocketAddress(port), 20);
                String cachepath = settings.getCachepath();
                if(!cachepath.startsWith("/")) cachepath = "/"+cachepath;
                server.createContext(cachepath, new HTTPServerHandler());
    If any of you guys can point to what I can do in order to solve this I would really appreciate it.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

Similar Threads

  1. Replies: 0
    Last Post: 03-14-2011, 08:56 AM
  2. Connect Syslog server with Java
    By may28 in forum New To Java
    Replies: 0
    Last Post: 01-07-2011, 02:40 PM
  3. server java HTTP request
    By kptN in forum New To Java
    Replies: 0
    Last Post: 10-22-2010, 04:42 PM
  4. How to block Client request to connect with server
    By mfaizan24 in forum Networking
    Replies: 3
    Last Post: 02-28-2010, 08:26 PM
  5. Server not able to connect client
    By Kapil Gupta in forum New To Java
    Replies: 15
    Last Post: 07-22-2008, 05:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts