Solved

RMI callbacks problem

Posted on 2002-06-09
7
443 Views
Last Modified: 2012-08-13
Hi,
I'm running an RMI application with callbacks.
Usually it works fine, but occasionally, when the server tries to invoke a method on the client the following exception is thrown in the server side:

java.rmi.ConnectException: Connection refused to host: <client ip address>; nested exception is:
        java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
        at java.net.Socket.<init>(Socket.java:273)
        at java.net.Socket.<init>(Socket.java:100)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:25)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:120)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83)
        at com.sanrad.nms.client.comm.CommunicationEventService_Stub.elementCreate(CommunicationEventService_Stub.java:37)
        at com.sanrad.nms.server.logic.EventServiceImpl.fireElementCreate(EventServiceImpl.java:49)
        at com.sanrad.nms.server.logic.ClusterImpl.newElement(ClusterImpl.java:97)
        at com.sanrad.nms.server.mgr.EventMgr.sendAddElementEvent(EventMgr.java:70)
        at com.sanrad.nms.server.mgr.CreateElementThread.run(CreateElementThread.java:36)

What could be the cause?
0
Comment
Question by:s_lavie
7 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7065138
 I remember a few months ago I had the same problem as well but I was working on a Linux machine (I am not sure what operating system you are using) and I was trying to connect to the localhost.

  I was invoking the getLocalHost() method to construct the rmi url and this was returning the loop-back interface address. What I did was to change the order of the IP address in the /etc/hosts file and move the localhost IP at the end (and had the eth0 name/IP address at the top).

  I am not sure if it helps but it might give you some clues.
0
 
LVL 2

Author Comment

by:s_lavie
ID: 7065144
well, I'm working on win2000.
I'm not sure your description fits mine, but thanks anyway ;-)
0
 
LVL 35

Expert Comment

by:girionis
ID: 7065530
 Sorry I did not help. It is really weird though because form what you say it seems that it connects and works properly and all of a sudden it throws an exception.

  Things you have to consider. Is the method called succesfully at some earlier point and fails at some later? Is the method called for the first time and raises an exception? If the latter is the issue then there is obviously something wrong with the method call itself. If not then there must be something wrong under the TCP/IP covers.

  The machine you are trying to connect might accept a limited number of connections only and when this number is reached then it raises an exception indicating that it accepts no more connections.

  There is usually a generic TCP/IP listener that you are trying to connect and each vendor implements it differently. This means that this listener has a count of connections and when this count is reached then it will "hand up" and will refuse further connections. One possible solution is that you might be exceeding the connections limit because you have loads of connections or too many things are trying to connect to quickly.

  I guess this limit is configurable so you could actually increase the number of connections (although I am not sure how you could do it). But, if this is the problem, I would suggest to find out first why this limit is reached.

  Hope it helps. Apart from thsi I cannot think of anything else why your connection is refused.

  Hope it helps.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 16

Expert Comment

by:heyhey_
ID: 7066289
Connection refused means that remote TCP stack does not accept your TCP (SYN ?) packet. that usually means that some of the TCP buffers on the remote machine are full.

in your case, it seems that ServerSocket backlog must be increased.

************

public ServerSocket(int port, int backlog) throws IOException
Creates a server socket and binds it to the specified local port number, with the specified backlog. A port number of 0 creates a socket on any free port.

The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused.
0
 
LVL 2

Author Comment

by:s_lavie
ID: 7066299
I found the problem. It was a silly bug, and to tell you the true I feel quite a shame...
I'll tell you anyway.
The bug was: making a call to a client that was disconnected from the server. Obviously the call failed, and instead of continue calling the other clients I just exited the method.
Sorry for the bothering, but thanks anyway ;-)
0
 
LVL 35

Expert Comment

by:girionis
ID: 8834293
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- To be PAQ'ed and points refunded

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 8910297
Question is PAQ'd and points refunded.

YensidMod
EE Moderator
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
GUI builder for Eclipse? 8 35
servlet example 11 40
by zero exception 10 40
Is there a simpler dropbox system? 10 20
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question