aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes More than 17 clients CRASH?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "More than 17 clients CRASH?!" Watch "More than 17 clients CRASH?!" New topic
Author

More than 17 clients CRASH?!

Ho An
Greenhorn

Joined: Oct 25, 2000
Posts: 10
Hi everyone,
I am testing my bookSeat() method with the multithread clients. It seems okay when I have generated below 16 Threads to test lock/unlock but more than 16 Threads gives me the error below. I could see all the lock/unlock behavior works well up until 16 Threads.
I know �java.net.ConnectException� usually related �java.policy�file but I gave all security permission. Also, if this is related �java.policy� file why Threads with below 16 is working?
I am stuck here for long time. Please help me guys.
java.rmi.ConnectException: Connection refused to host: 192.168.254.31; nested ex
ception 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(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at suncertify.db.DataAccessFactory.getDataAccess(DataAccessFactory.java:
47)
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Ho,
(Gee I suddenly feel shorter)
I think the problem has to do with the system not willing to give you any more resources. What hardware platform are you using? Do you have super-user/administrative privaleges? These and other things can affect the allocation of system resources.

Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Ho An
Greenhorn

Joined: Oct 25, 2000
Posts: 10
Here goes my environment.
I have implemented ConnectionFactory as a UnicastRemoteObject. Each client gets the unique clientId. It seems like the lookup name,"ConnectionFactory ", can not be found the after about 16 client ID's are generated with thread. Please somebody help me what is going on.
Thanks,
Ho An.
Ho An
Greenhorn

Joined: Oct 25, 2000
Posts: 10
Hi Michael,
I am using Windows 2000 with Admin privalege. I initially thought I might have unnecessary class created inside while loop of lock/unlock which will use up all the resources but I think I don't have anything suspicious. I even used "System.gc()" couple of places which did not help at all.
I might have problem in my LockManager. Here goes my lock/unlock. I have used HashMap as "lock". Please help me out.

Thanks,
Ho An.
Ho An
Greenhorn

Joined: Oct 25, 2000
Posts: 10
You guys okay with more than 16 clients(Thread) in your machine when you are testing? or my case is normal?
Anybody please comment,
Ho An.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Ho,
Why do you need to wait in your unlock method? If the clientID matches what you have in the Map, just remove it and notifyAll. I can't say for sure but you may be creating the potential for a dead lock by waiting in the unlock method. If the clientID does not match, just ignore it as the instructions indicate.
As for the problem with the 17th thread, I still think it has to do with system constraints but I could be wrong. If you have access to a different OS, like Linux or even a less restrictive Windows like 98, you could test this theory.
Hope this helps,
Michael Morris
I went back and checked my lock test and I never started more than ten clients and I also used Windows 2000.
[ August 16, 2002: Message edited by: Michael Morris ]
Ho An
Greenhorn

Joined: Oct 25, 2000
Posts: 10
Thank you Michael for ULTRA SUPER FAST reponse.
I remove the wait method in unlock and still have the same problem with 17th client Thread. I will test with the other platforms. I wonder if you application can survive more than around 16-18 client Threads though.
Thank you again,
Ho An.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Ho,
I'm at home today and don't have a 2K machine but I'll try to set up a test on 98 later this evening. It's my 22nd Anniversary, so I have to be careful about playing with the computer too much today or I and the dogs will be sharing a bed tonight!
Michael Morris
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

I remove the wait method in unlock and still have the same problem with 17th client Thread.

I don't think your problem is in locking. I had the same behaviour in my testing, -- if I create too many threads representing the remote clients, I got the exception "connection refused...". My threshold was somewhere about 25 clients, after which the problem occured. I remember some other people reported this.
I believe the problem is in Sun's RMI implementation, -- the RMI server chokes under a bombardment of requests to connect. Weblogic server actually offers its own implementation of RMI, because Sun's implementation is not robust.
I don't think you need to worry about this. Test with 15 clients each trying to book the same flight 100 times. If at the end the seat count is reduced by exactly 1500, you are fine.
You may also try to sleep() a little before the connect requests, -- give your RMI server a break, maybe it will help to serve more connections.
Eugene.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

I have to be careful about playing with the computer too much today or I and the dogs will be sharing a bed tonight!

Forcing zoophilia is a cruel and unusual punishment, and all wives are impeachable.
Eugene.
Ho An
Greenhorn

Joined: Oct 25, 2000
Posts: 10
Thank you Eugene.
I am glad I am not the only one who has this problem. I will try what you said too. You guy are great
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

Forcing zoophilia is a cruel and unusual punishment, and all wives are impeachable.

At least the dogs let you drink as much Tequila as you want and don't complain when you light up a good Cuban!

Michael Morris
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

At least the dogs let you drink as much Tequila as you want and don't complain when you light up a good Cuban!

I have as much fun with cats, Vodka, and pot (with the same adjectives applied)!
Eugene.
XJ LIN
Greenhorn

Joined: Feb 05, 2002
Posts: 18
I am testing my bookSeat() method with the multithread clients. It seems okay when I have generated below 30 Threads to test lock/unlock but more than 30 Threads gives me the the same error like you. how do you fixed it?
I use windowXP.
thanks,
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
If not 17 clients or 25 then 50 clients or 100 clients. No system is going to be able to provide you with unlimited threads. Why not figure out how many threads are reasonable for your environment (make it an entry in a config file) and then pool your threads. When someone requests a thread beyond what is available either make them wait or give them a "system too busy - try again later" message.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Bob Reeves
Ranch Hand

Joined: May 01, 2003
Posts: 64
Hi All:
My assignment is the URLyBird application. I'm using SDK 1.4.1_03, and I'm also seeing this "Connection Refused (CR)" problem. I'm running 20 threads, and on some runs everything works. But most often I get a bunch on passes, then about four CRs, finally things recover and proceed correctly. The CRs always seemn to start about one second into the run. This is a very unwelcome problem just when I thought everything was shippable! Luckily, on URLyBird, SUN can't easily test this (the RMI stuff) because they don't require the remote object to follow the database interface.
Tx
S. Ganapathy
Ranch Hand

Joined: Mar 26, 2003
Posts: 194
Hi All,
I am also facing the same problem. Like connect exception. Further twice I found client got hanged. It was strange to me. And I tried to reproduce the same, and I could not.

The above works fine, but throws some exceptions like:

Twice I found client got hanged, but if I ran the client from another window, it worked. Can i anticipate dead-lock situation?, as I also have doubt that I am trying to create as many threads as possible. Dead-lock like situation occurred when the loop counter was at "i < 500;"
My JDK version is 1.4.1, and OS version is Win 2000 Professional. No service packs were installed. RAM 512MB, Intell PIII 500MHz.
I am using wait() only while locking the record, and no where else. Locking is only at server side.
Please provide you comments.
Regards,
Ganapathy.
Perry Board
Greenhorn

Joined: May 03, 2003
Posts: 29
In my testing I also had some connection exceptions but it appeared to be simply a result of rapid repeated connection attempts (loop that spawns 100 threads all trying to contact the RMI registry for a connection). If I put the thread to sleep for a fraction of a second in between connection attempts, it appeared to work ok.
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Originally posted by Perry Board:
In my testing I also had some connection exceptions but it appeared to be simply a result of rapid repeated connection attempts (loop that spawns 100 threads all trying to contact the RMI registry for a connection). If I put the thread to sleep for a fraction of a second in between connection attempts, it appeared to work ok.

This was true of my experience in testing as well. I was getting connection exceptions with as few as 15 clients. The problem is almost certainly due to the inability of the RMI registry to handle so many connections in such a short period of time. As you point out this is easily fixed by adding a Thread.currentThread().sleep(100) statement before each connection attempt. After doing so, I was able to test with 330 clients each doing 200 booking operations. I recommend taking a look at the sample testing harness in Max's book. It's definitely the way to go.
In my case, I had 33 records in the database file, so I wanted to have 10 clients per database record, with each client booking the database record 200 times. My booking test operation was simply to read the record, increment the customer ID number, and then update the record. Before starting I initialized all the customer ID's in the database file to zero. The advantage to doing this is that when my test finished I only had to start my Client GUI and look at the customer ID's of all the records. I expected each record to show a customer ID of 2000 (10 clients x 200 increment operations per client) and they did. In this way checking the results of your test is incredibly easy.
-George


Regards, George
SCJP, SCJD, SCWCD, SCBCD
 
Don't get me started about those stupid light bulbs.
 
subject: More than 17 clients CRASH?!