• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.rmi.ConnectionException

 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just implented a test suite for the assignement. While testing everything on one maschine (Windows 2000, jdk1.3.1 or 1.4.1)
if my client generate more than 20 Threads
- some of the threads crash by getting following Exception:
java.lang.RuntimeException: java.rmi.ConnectException: Connection refused to host: 169.254.5.243; nested exception i
s:
java.net.ConnectException: Connection refused: connect
at suncertify.test.TestDB.create(TestDB.java:135)
at suncertify.test.TestServer$CreateRunnable.run(TestServer.java:243)
at java.lang.Thread.run(Thread.java:536)
Caused by: java.rmi.ConnectException: Connection refused to host: 169.254.5.243; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
at suncertify.server.DataRemote_Stub.create(Unknown Source)
at suncertify.test.TestDB.create(TestDB.java:126)
... 2 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:434)
at java.net.Socket.connect(Socket.java:384)
at java.net.Socket.<init>(Socket.java:291)
at java.net.Socket.<init>(Socket.java:119)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
... 7 more

I have standart property and policy files.
It seems that I should change some properties to allow RMI open more sockets. Do you know how can I change it and why it occurs?
Thanx,
Vlad
P.S. I have tried to run both the server and client with these properties:
-Dsun.rmi.transport.proxy.connectionTimeout=600000
-Dsun.rmi.transport.proxy.connectTimeout=600000
, but it didn't help.
I have
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before we start, did you test with, say, 5 or 10 threads? As I recall, my laptop stopped serving connections after 17.
Of course, it doesn't matter what your upper limit for connections is: there's going to be one(a limit, that is). If this isn't a logical problem, I'd let it go. Twenty's as good a number as any. There are probably other issues you could be addressing: and if there aren't, submit your test already.

M
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
It works perfect with 15-17 Threads,
after that I get the "surprices"
Well, I am absolutelly sure: it is not my bug:
I have a simple architecture one ConnectionFactory object with synchronized getConnection() method, which creates a remote object.
Vlad.
 
Svetlana Koshkina
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vlad Rabkin:
Hi Max,
It works perfect with 15-17 Threads,
after that I get the "surprices"
Well, I am absolutelly sure: it is not my bug:
I have a simple architecture one ConnectionFactory object with synchronized getConnection() method, which creates a remote object.
Vlad.

I do not know what's your problem is but i swear, i saw topics here where people address exact same problem, you can search.
I only can tell that I did not test my assignment on two machines because i have only one at the moment but since i tested rmi on two machines in general i believe that everything will be as good as loopback on the same host (localhost).
And I am able to run as many clients as my computer can endure. I am getting this kind exception when my server is not listening.
I thought why it can be, and the only idea being: occurences of deadlocks in your clients.
To sort everything out you need to run with multiple local clients, multiple remote clients on the same machine and only then: multiple remote clients on other machine.
???
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Svetlana is right - this was discussed very recently. You can read about it in this thread.
It is possible that you may be experiencing the same problem as others: if you try and get too many connections too quickly Sun's rmiregistry causes the exception you noted. Simple solution: pause for a little while between connections.
Personally I only had around 10 connections on my automated test. On a manual test I managed to get up to 30 connections simultaneously, but I don't remember what thread I posted that bit of information in.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic