Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 854473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:55:43+00:00 2026-05-15T07:55:43+00:00

I’ve been using RMI in this project for a while. I’ve gotten the client

  • 0

I’ve been using RMI in this project for a while. I’ve gotten the client program to connect (amongst other things) to the server when running it over my LAN, however when running it over the internet I’m running into the following exception:

java.rmi.ConnectException: Connection refused to host: (private IP of host machine); nested exception is: 
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy1.ping(Unknown Source)
at client.Launcher$PingLabel.runPing(Launcher.java:366)
at client.Launcher$PingLabel.<init>(Launcher.java:353)
at client.Launcher.setupContentPane(Launcher.java:112)
at client.Launcher.<init>(Launcher.java:99)
at client.Launcher.main(Launcher.java:59)

Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 12 more

This error is remeniscent of my early implementation of RMI and I can obtain the error verbatum if I run the client locally without the server program running as well. To me Connection Timed Out means a problem with the server’s response.

Here’s the client initiation:

public static void main(String[] args)
{
    try
    {
        String host = "<WAN IP>";
        Registry registry = LocateRegistry.getRegistry(host, 1099);
        Login lstub = (Login) registry.lookup("Login Server");
        Information istub = (Information) registry.lookup("Game Server");
        new Launcher(istub, lstub);

    }
    catch (RemoteException e)
    {
        System.err.println("Client exception: " + e.toString());
        e.printStackTrace();
    }
    catch (NotBoundException e)
    {
        System.err.println("Client exception: " + e.toString());
        e.printStackTrace();
    }
}

Interestingly enough no Remote Exception is thrown here.
Here’s the server initiation:

public static void main(String args[])
{
    try
    {
        GameServer gobj = new GameServer();
        Information gstub = (Information) UnicastRemoteObject.exportObject(
                gobj, 1099);
        Registry registry = LocateRegistry.createRegistry(1099);
        registry.bind("Game Server", gstub);

        LoginServer lobj = new LoginServer(gobj);
        Login lstub = (Login) UnicastRemoteObject.exportObject(lobj, 7099);

        // Bind the remote object's stub in the registry
        registry.bind("Login Server", lstub);

        System.out.println("Server ready");
    }
    catch (Exception e)
    {
        System.err.println("Server exception: " + e.toString());
        e.printStackTrace();
    }
}

Bad practice with the catch(Exception e) I know but bear with me.

Up to this stage I know it works fine over the LAN, here’s where the exception occurs over the WAN and is the first place a method in the server is called:

private class PingLabel extends JLabel
{
    private static final long serialVersionUID = 1L;

    public PingLabel()
    {
        super("");
        runPing();
    }

    public void setText(String text)
    {
        super.setText("Ping: " + text + "ms");
    }

    public void runPing()
    {
        try
        {
            PingThread pt = new PingThread();
            gameServer.ping();
            pt.setRecieved(true);
            setText("" + pt.getTime());
        }
        catch (RemoteException e)
        {
            e.printStackTrace();
        }
    }
}

That’s a label placed on the launcher as a ping test. the method ping(), in gameserver does nothing, as in is a null method.

It’s worth noting also that ports 1099 and 7099 are forwarded to the server machine (which should be obvious from the stack trace).

Can anyone see anyting I’m missing/doing wrong? If you need any more information just ask.

EDIT: I’m practically certain the problem has nothing to do with my router settings. When disabling my port forwarding settings I get a slightly different error:

Client exception: java.rmi.ConnectException: Connection refused to host: (-WAN IP NOT LOCAL IP-);

but it appears both on the machine locally connected to the server and on the remote machine.

In addition, I got it to work seamlessly when connecting the server straight tho the modem (cutting out the router. I can only conclude the problem is in my router’s settings but can’t see where (I’ve checked and double checked the port forwarding page). That’s the only answer i can come up with.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:55:43+00:00Added an answer on May 15, 2026 at 7:55 am

    Are you using NAT (Network Address Translation)? This is the typical case if your LAN uses non-routable address behind a router (like 10.x or 192.169.x etc).

    If this is the case, you need to specify the public IP of the server with following option,

    -Djava.rmi.server.hostname=host_name_or_public_ip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't know if it's the answer you're looking for, but… May 16, 2026 at 4:59 pm
  • Editorial Team
    Editorial Team added an answer Syntax errors are just what it says they are, the… May 16, 2026 at 4:59 pm
  • Editorial Team
    Editorial Team added an answer I think you can either roll your own, this tutorial… May 16, 2026 at 4:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.