java.net.connectexception connection timeout

hi i am using this codes for rmi

RmiServer.java

import java.rmi.*;

import java.rmi.registry.*;

import java.rmi.server.*;

import java.net.*;



public class RmiServer extends java.rmi.server.UnicastRemoteObject

implements ReceiveMessageInterface

{

    int      thisPort;

    String   thisAddress;

    Registry registry;    // rmi registry for lookup the remote objects.



    // This method is called from the remote client by the RMI.

    // This is the implementation of the gReceiveMessageInterfaceh.

    public void receiveMessage(String x) throws RemoteException

    {

        System.out.println(x);

    }



    public RmiServer() throws RemoteException

    {

        try{

            // get the address of this host.

            thisAddress= (InetAddress.getLocalHost()).toString();

        }

        catch(Exception e){

            throw new RemoteException("can't get inet address.");

        }

thisPort=3232;  // this port(registryfs port)

        System.out.println("this address="+thisAddress+",port="+thisPort);

        try{

        // create the registry and bind the name and object.

        registry = LocateRegistry.createRegistry( thisPort );

            registry.rebind("rmiServer", this);

        }

        catch(RemoteException e){

        throw e;

        }

    }



    static public void main(String args[])

    {

        try{

        RmiServer s=new RmiServer();

    }

    catch (Exception e) {

           e.printStackTrace();

           System.exit(1);

    }

     }

}

RmiClient.java

import java.rmi.*;
import java.rmi.registry.*;
import java.net.*;

public class RmiClient
{
    static public void main(String args[])
    {
       ReceiveMessageInterface rmiServer;
       Registry registry;
       String serverAddress=args[0];
       String serverPort=args[1];
       String text=args[2];
       System.out.println("sending "+text+" to "+serverAddress+":"+serverPort);
       try{
           // get the �gregistry�h
           registry=LocateRegistry.getRegistry(
               serverAddress,
               (new Integer(serverPort)).intValue()
           );
           // look up the remote object
           rmiServer=
              (ReceiveMessageInterface)(registry.lookup("rmiServer"));
           // call the remote method
           rmiServer.receiveMessage(text);
       }
       catch(RemoteException e){
           e.printStackTrace();
       }
       catch(NotBoundException e){
           e.printStackTrace();
       }
    }
}

ReceiveMessageInterface.java

 import java.rmi.*;

public interface ReceiveMessageInterface extends Remote

{

  public   void receiveMessage(String x) throws RemoteException;


}

This works fine normally , but when the a computer is connected to internet through mobile or it shares internet from other pc it doesn't work

I get this error.

java.net.connectexception connection timeout

when i tried to telnet it fails to connect but when i try to run this program that pc to my pc it works.

Please let me know how to solve this issue.

Answers


Sounds like a firewall or proxy server issue.


Need Your Help

PHP `exec` in the background but get STDOUT

php background exec fork

I'm trying to execute a command (in both Windows and Linux) via PHP. My target is to have multiple instances of the command running at the same time (hence background) but I need to grab the output...

Send executable jar to hadoop cluster and run as “hadoop jar”

hadoop cloud bigdata

I commonly make a executable jar package with a main method and run by the commandline "hadoop jar Some.jar ClassWithMain input output"

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.