• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.rmi.ConnectException: Connection refused to host

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I have a stateless session bean running on my glassfish server and tens of clients for it, invoking the business method poll() of this bean. The code is like this:



Please, note that the poll() method makes a lookup for a remote object exported to the RMI Registry and so invokes the pushRead() method on it. This method is synchronized due to concurrent access. Sometimes in my server log I see exceptions like this:



They are raised by this method execution. I have already set in the java.security file the following properties but the problems carries on.



Any advices/tips?

Thanks,

Rafael.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the relation b/w connection refused and the network address cache settings?

The IP shown in the connect exception is the IP of your server?
Does your RMI server crash in between?
 
Rafael Z. Frantz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nitesh,

The IP is the IP of my local machine at home. It is strange, because sometimes I this message, with different IPs or even the localhost address, like this:







All these errors at the same execution for the same code. And besides,, in different lines each time:



The RMI server does not crash.

It is strange because the RMI server seems to return different addresses. I´ve added this when starting the rmi server:

start rmiregistry -J-Djava.rmi.useLocalHostName=true -J-Djava.rmi.server.hostname=127.0.0.1

seems to be more stable, but I am not sure.


Thanks!
 
Ranch Hand
Posts: 99
Postgres Database Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had this same problem. You pass up the serverIP and get back the internal IP address of the server. Since your machine has no clue how to reconcile it, you get a connect, refuse message. Sometimes you'll get back a connect, refuse to "127.0.0.1" and sometimes it will be to "98...." but it's always the internal address of the server. We tried all kinds of things with mappings in our router to fix this. We finally gave up and made the client call local host until we can revisit this and figure out what is wrong with our topology.
 
Rafael Z. Frantz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Al,

Yes, this is exactly the problem I have. In order to isolate the problem, I've disabled all connection adapters of my machine. In this case it works fine with 127.0.0.1 but at the time I-ve enabled one connection giving to the machine one IP the problem comes back and sometimes the message conection refused for 127.0.0.1 appears and/or for the other IP. I am doing the same as you, using localhost and it seems to work fine.

Have you tried the parameters I've mentioned to start the rmi registry?

Regards,
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rafael Z. Frantz wrote:Hi Al,

Yes, this is exactly the problem I have. In order to isolate the problem, I've disabled all connection adapters of my machine. In this case it works fine with 127.0.0.1 but at the time I-ve enabled one connection giving to the machine one IP the problem comes back and sometimes the message conection refused for 127.0.0.1 appears and/or for the other IP. I am doing the same as you, using localhost and it seems to work fine.

Have you tried the parameters I've mentioned to start the rmi registry?

Regards,



Hi Friends,

If you have confusion about ip of rmi server, I have a suggestion for you. After starting your rmi registry...you can check status of registry before connecting by rmi client.

Please start command prompt, and say 'telnet ip_of_server_you_make_rmi_registry_On port_for_rmi_Registry'.
you will get a blank window waiting for your input. (Name of window being Telnet host).
i.e. telnet 127.0.0.1 1099

1099 is default port for rmi registry, you can use other as well.

Once you try this out you will be sure about exactly which is the IP and port of your registry, Then it is good time to connect using client

 
Rafael Z. Frantz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nishikant,

I understand your point. We are sure about the ip of our server, since it was started with a fix ip. The problem is that the client at the same execution, makes a lookup and then invoke the stub method, and during this time, sometimes the server seems to be listening to 127.0.0.1, sometimes to other IP. Please, note that the rmi registry server, as introduced at the beginning of this post, was started with a fix IP and port.

 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at java.rmi.server.hostname here
 
Rafael Z. Frantz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nitesh!

First of all thanks for the link.

I am starting the rmi registry with the following params:



And my application that exports 2 objects (Entry Ports) to rmi registry with the following options:



I have noticed that in my server log I am still getting this exeception:


Please note that the ThreadID is in some cases very high, like 229. I am wondering if this is the number of threads a I may have? Besides, is threre any limit of threads that concurrently does a lookup for a remote object? If there is a limit, maybe this could be the problem, since I have a lot of threads..

The parameters above didn´t elp :-(

 
Al Johnston
Ranch Hand
Posts: 99
Postgres Database Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, Rafael (and others). There are a couple of good ideas in this thread for our networking guy and for me to try. I'll let you know if it solves my problem. It would sure be good to get to the bottom of this. As for now, using localhost works, but that sort of defeats the purpose of what we are trying to do...
 
Rafael Z. Frantz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Al,

I've tried to add localhost when exporting objects to registry and when starting the RMI registry as well. It helps, but I'm not sure it solves the problem. Take a look in my last post here, I still got this exception for localhost. It is right that at least now the connection address at the exception is always the same, but as I've noticed does not solve the problem 100%. Once again, I think this is also related with the number of threads making a lookup at the RMI registry. Please note that I have around 200 threads concurrently doing a lookup. Can you also create several threads and test if you also get this exception?

Thanks,

Rafael.
 
Al Johnston
Ranch Hand
Posts: 99
Postgres Database Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rafael,

That's a good warning. Our platform is serving the internet with several thousand lookups per hour. I'm sure we'll have at least 200 threads running - but will be putting in a load balance server as well. I will create 300 threads that are calling the RMI server tomorrow and see if I can reproduce any problems.

Best,
Al
 
Rafael Z. Frantz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Al,

Good, let´s see if you have the same problem.


Thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic