I have a small server, which works under Windows and fails under Red Hat. The idea is:
- a main thread with a ServerSocketChannel and a Selector
- when it accepts a connection, it creates an Event with the SocketChannel in it
- the Event is offered to the Queue
- each Worker thread has its own Selector and a DB Connection
- the Worker thread takes the Event from the Queue, sets the Selector and the DB Connection in it and calls Event's method getProcessed
- the Event reads the SocketChannel (always fine), queries the DB (always fine) and writes to the SocketChannel (works under Windows and fails under Red Hat)
the code is:
I will appreciate any comments and suggestions.
When it fails under Red Hat the browser shows "The connection was reset". Although only twice (out of 50 attempts) I got the correct response under Red Hat - judging by the log - the Opera browser has tried 4 times in a row and eventually has got the response.
When it succeeds and when it fails, the log is always perfect: