Solved

RMI callbacks problem

Posted on 2002-06-09
7
438 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java asynchronous logging 4 50
print map entry 34 55
more than one jdk and one jre 1 34
arguments to jar 5 15
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now