• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The concurrent problem about RMI

 
Along huang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

In server side, I register only one RMI object, and I write a class with some concurrent threads to test the Remote object.

When the concurrent threads count is within 30, it is ok, but the concurrent threads count is up to 50, it always raise a error, the error message is as below,


java.rmi.ConnectException: Connection refused to host: 192.168.18.63; 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.db.DBServiceRMIImpl_Stub.executeUpdate(Unknown Source)
at suncertify.business.proxy.DBProxyRMIImpl.executeUpdate(DBProxyRMIImpl.java:36)
at suncertify.TestConcurrent$TestThread.run(TestConcurrent.java:123)
at java.lang.Thread.run(Thread.java:534)
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:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
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 am in predicament, how should I do now?

best regards
 
Po Sun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm facing the same issue as yours when testing the RMI unit. My understanding about this problem is it evoked by the concurrent conconnection limit of our OS.AFAIK, windows xp sp2 set only 10 TCP concurrent connection available by default. When we use multi-thread to test
lock mechanism, it could break the limitation,so the above you said appears.
Anyone has better idea?
 
Song Lixin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implement a RMI DBClientFactory which is registered at RMI Registry.
I then create DBClient at remote call. In the factory, I restrict the number of DBClient to 20. If the limit is exceeded, it just return a ServerBusy exception.

BTW, I set it to 100 before I changed it, but I meet the same problem when testing. As a turn around to the issue, I just changed the limit to 20.
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

make a reasonable interpretation of what your assignment sais (explicitly or implicitly) about the total number of clients per server and the maximum likely total number of concurrent connects. Document that interpretation in your choices.txt. Make sure that it works for these numbers. In my case I did not have to change anything. When every 3 years one client in the company gets an error message because of this connect problem which has no greater impact (click ok and try again) then it's ok.

I made it so and got 100 % in general considerations and documentation.

Conan
 
Dieskun Koper
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I encountered the same error message when testing. Up to 20 clients no problem, but above that connections were refused.
I googled it up and eventually found an entry in the bug parade.
If, instead of starting all your clients at the same time, put a half a second delay between them, you will probably have no problems anymore.
 
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
Hi everyone,

You might want to look at this thread.

For testing purposes, try following Dieskun's suggestion of putting a delay into your loop making connections.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic