Le 2/22/12 9:38 AM, Alexander Christian a écrit :
Hi there,
Hi,
following scenario:
A MINA powered server application is reading data from network, which
is sent by any client. While server is getting data, the connection
get's broken. The read() from server is interrupted and
exceptionCaught() in IoHandler is called.
Currently, my exceptionCaught() implementation looks like this:
----
@Override
public void exceptionCaught(IoSession session, Throwable
throwable) throws Exception {
logger.error("exception Caught. session={}. Exception:\n {}",
new Object[]{Utils.longToHexString(session.getId()),
Utils.getStackTraceAsString(throwable)});
logger.debug("Closing the session now! session={}",
Utils.longToHexString(session.getId()));
session.close(true);
}
----
Problem is, that I don't know how to differentiate between "real and
important exceptions", which need to be logged more prominent and
exception which might occur because of a client has been disconnected
correctly (broken network connection). if a connection get's broken, I
just get a generic IOException:
----
Feb 21, 2012 5:10:20 PM de.root1.simon.Dispatcher exceptionCaught
Schwerwiegend: exception Caught. session=0x00000002. Exception:
java.io.IOException: Die Verbindung wurde vom Kommunikationspartner
zurückgesetzt
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:218)
at sun.nio.ch.IOUtil.read(IOUtil.java:191)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359)
at
org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:280)
at
org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:44)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:695)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1141)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
----
How can I handle broken connections properly?!
Not an easy question... MINA is lacking a set of exceptions to properly
inform the user about what is going on.
Can you fill a JIRA requesting for at least an ErrorCode to be returned ?
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com