Solved

RMI callbacks problem

Posted on 2002-06-09
7
447 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

730 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