943,840 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5385
  • Java RSS
Apr 23rd, 2008
0

Rmi by Internet connection

Expand Post »
Hai Friends

Iam using RMI concept for my project, i want to connect client and server by using internet connection , but its working fine on LAN connection, it gives following Exception
Java Syntax (Toggle Plain Text)
  1. java.lang.RuntimeException: java.rmi.ConnectException: Connection refused to hos
  2. t: 125.17.11.229; nested exception is:
  3. java.net.ConnectException: Connection refused: connect
  4. at Client.init(Client.java:23)
  5. at sun.applet.AppletPanel.run(AppletPanel.java:417)
  6. at java.lang.Thread.run(Thread.java:619)
  7. Caused by: java.rmi.ConnectException: Connection refused to host: 125.17.11.229; n
  8. ested exception is:
  9. java.net.ConnectException: Connection refused: connect
  10. at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
  11. at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198
  12. )
125.17.11.229 is my internet IP

my code
Java Syntax (Toggle Plain Text)
  1. Server:
  2. import java.rmi.registry.LocateRegistry;
  3. import java.rmi.registry.Registry;
  4. import java.rmi.server.UnicastRemoteObject;
  5.  
  6. public class Server implements RemoteInterface
  7. {
  8.  
  9. public String getMessage()
  10. {
  11. return "Hello World";
  12. }
  13.  
  14. public static void main(String args[])
  15. {
  16. try
  17. {
  18. String REGISTRY_NAME = "RMI_Example";
  19. int REGISTRY_PORT = 3032;
  20. Registry registry = LocateRegistry.getRegistry(REGISTRY_PORT);
  21. RemoteInterface remoteReference =
  22. (RemoteInterface) UnicastRemoteObject.exportObject(new Server());
  23. registry.rebind(REGISTRY_NAME, remoteReference);
  24. }
  25. catch (Exception e)
  26. {
  27. throw new RuntimeException(e);
  28. }
  29. }
  30. }
  31.  
  32. Interface:
  33.  
  34. import java.rmi.Remote;
  35. import java.rmi.RemoteException;
  36.  
  37. public interface RemoteInterface extends Remote
  38. {
  39. String getMessage() throws RemoteException;
  40. }
  41.  
  42.  
  43. client:import java.rmi.registry.LocateRegistry;
  44. import java.rmi.registry.Registry;
  45. import javax.swing.JApplet;
  46. import javax.swing.JLabel;
  47. import java.rmi.*;
  48.  
  49. public class ClientApplet
  50. {
  51.  
  52. public static void main(String arg[])
  53. {
  54. String REGISTRY_NAME = "RMI_Example";
  55. int REGISTRY_PORT = 3032;
  56.  
  57. try
  58. {
  59. Registry registry =
  60. LocateRegistry.getRegistry("125.17.11.229",REGISTRY_PORT);
  61. RemoteInterface remoteReference =
  62. (RemoteInterface) registry.lookup(REGISTRY_NAME);
  63. System.out.println(remoteReference.getMessage());
  64. }
  65. catch (Exception e)
  66. {
  67. throw new RuntimeException(e);
  68. }
  69. }
  70. }
plz help me for this problem...
Last edited by ~s.o.s~; Apr 30th, 2008 at 4:01 pm. Reason: Added code tags, learn to use them.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Venks is offline Offline
35 posts
since Feb 2007
Apr 23rd, 2008
0

Re: Rmi by Internet connection

Firewall?
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Apr 23rd, 2008
0

Re: Rmi by Internet connection

either that or the server process is bound to the local network address and therefore trying to call the process through its external address isn't going to get a response.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Apr 29th, 2008
0

Re: Rmi by Internet connection

When iam using external ip(125.17.11.232) to connect server its working fine in LAN but it gives error when iam try to run in internet connection
Exception in thread "main" java.lang.RuntimeException: java.rmi.ConnectIOExcepti
on: Exception creating connection to: 194.9.30.245 nested exception is:

In error show my server local ip 194.9.30.245 ,

coding:
Server :
Server.java

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class Server implements RemoteInterface
{

public String getMessage()
{
return "Hello World";
}

public static void main(String args[])
{
try
{
String REGISTRY_NAME = "RMI_Example";
int REGISTRY_PORT = 60020;
Registry registry = LocateRegistry.getRegistry(REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) UnicastRemoteObject.exportObject(new Server());
registry.rebind(REGISTRY_NAME, remoteReference);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
--------------------------------------
Interface
RemoteInterface.java

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface RemoteInterface extends Remote
{
String getMessage() throws RemoteException;
}
-----------------------------------------------------------
Client

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.swing.JApplet;
import javax.swing.JLabel;
import java.rmi.*;

public class ClientApplet
{

public static void main(String arg[])
{
String REGISTRY_NAME = "RMI_Example";
int REGISTRY_PORT = 60020;

try
{
Registry registry =
LocateRegistry.getRegistry("125.17.11.232",REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) registry.lookup(REGISTRY_NAME);
System.out.println(remoteReference.getMessage());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}

Please send me solution for this problem
Reputation Points: 10
Solved Threads: 0
Light Poster
Venks is offline Offline
35 posts
since Feb 2007
Jul 2nd, 2008
0

Re: Rmi by Internet connection

any solution for this problem...
Reputation Points: 10
Solved Threads: 0
Light Poster
Venks is offline Offline
35 posts
since Feb 2007
Jul 2nd, 2008
0

Re: Rmi by Internet connection

Maybe, if you were to show what the nested exception is.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Jul 3rd, 2008
0

Re: Rmi by Internet connection

java.rmi.ConnectIOException: Exception creating connection to: 194.9.30.242; nested exception is:
java.net.NoRouteToHostException: No route to host: connect
this is my Exception
Reputation Points: 10
Solved Threads: 0
Light Poster
Venks is offline Offline
35 posts
since Feb 2007
Jul 3rd, 2008
0

Re: Rmi by Internet connection

That is, seemingly, not a publicly available ip address (i.e. can't be reached from the internet, at all), or you are attempting it to access throught the wrong interface on your computer, and so have no network path to it.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Jul 3rd, 2008
0

Re: Rmi by Internet connection

im using public ip in my client,what are the changes that i have to do in my program? in client or server program?
Reputation Points: 10
Solved Threads: 0
Light Poster
Venks is offline Offline
35 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Javax.sound.midi and midi messages
Next Thread in Java Forum Timeline: RMI server behind the firewall+nat enivironment





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC