Java NIO Framework stops working under heavy load with no write?

Edited after reading comments : After reading your comments I think number of sockets currently open with client seems to be problem. Opening an socket and keeping it open even when its idle certainly looks like problem. Each socket requires system resources like inode Try running ulimit if you are using linux NOTE: Its not recomended to set it to unlimited but you can try this: ulimit -u unlimited.

Edited after reading comments : After reading your comments I think number of sockets currently open with client seems to be problem. Opening an socket and keeping it open even when its idle certainly looks like problem. Each socket requires system resources like inode.

Try running ulimit if you are using linux. NOTE: Its not recomended to set it to unlimited but you can try this: ulimit -u unlimited.

There's no way to tell if the data is valid because it might have only came in half way or has two packets and a half, etc. – SSpoke Sep 17 '10 at 7:01 Man I appreciate for trying I really mean it but it doesn't have anything to do with too much sockets build-up it's a problem with selectionKey getting flooded then hanging.. so accepter key doesn't seem to ever trigger. As I wrote if I leave the server as a Echo/Bounce packet it will work unlimited as in I can spawn 500 sockets and disconnect them and spawn again over and over for about a hour?(didn't go further and it still allows new connections no problem.. but when I disable the send() method in read() method all of a sudden after 500 connections it won't accept connections. – SSpoke Sep 17 '10 at 12:52.

((SocketChannel)key.channel()).socket().close() You don't need all that. Change that to: key.channel().close() send() which changes SelectionKey into WRITE OPERATION I would want to see the details of that. More likely you are never getting out of the OP_WRITE state.

Really hard to do this. Since send just adds events which are processed by a thread that calls write subroutine which should change it back to READ operation if nothing else left to send – SSpoke Oct 29 '10 at 22:16 That's what I asked to see details of. You should generally just write when you need to write, always checking the return code.

If you get zero, switch to OP_WRITE. When that fires, write, and if you succeed in writing everything, switch back to OP_READ. Post your code.

– EJP Oct 29 '10 at 23:28 I am confused again sorry all the code I use is pretty much in the question. But some kind of lock happens or object gets disposed before it changes the I/O state – SSpoke Oct 31 '10 at 2:41 None of the sending code is in the question. I am now asking you for the third time to post it.

I can solve this problem for you but not like this. – EJP Nov 1 '10 at 0:40 Your opinion on my competence is (a) offensive and (b) irrelevant. I've told you how to handle writes.

You're welcome to try it any time you like. But cut out the irrelevant personal observations thanks. – EJP Nov 8 '10 at 2:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions