Solved

RMI callbacks problem

Posted on 2002-06-09
7
432 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

706 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

15 Experts available now in Live!

Get 1:1 Help Now