Hi everyone
I am currently using MINA 1.0.10 and am only new to MINA for the last
couple of months. I have searched the documentation, forums and mailing
lists for past few days trying to find if anyone else has this problem
but haven't been successful.
I am using an IoAcceptor to bind certain Handlers to certain ports. Each
port will have connections from GPRS modules that report in their
location and other data. Each GPRS module reports their data differently
so different handlers are required for each module.
Anyway the problem is, I get the following exception every now and then
(it seems randomly) and am not sure what is causing the exception to occur:
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcher.read0(Native Method)
at
sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
at
sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
at sun.nio.ch.IOUtil.read(IOUtil.java:206)
at
sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:254)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:234)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProcessor.java:46)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:539)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.lang.Thread.run(Thread.java:595)
In the Handler class I add the Filters in the sessionCreated method:
public void sessionCreated(IoSession session) throws Exception {
if (session.getTransportType() == TransportType.SOCKET) {
((SocketSessionConfig)
session.getConfig()).setReceiveBufferSize(2048);
}
// custom codec for this device
session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(
new CustomTextLineCodecFactory(Charset.forName("UTF-8"))));
session.getFilterChain().addLast("logger", new LoggingFilter());
}
The CustomTextLineCodecFactory is a modified class of
TextLineCodecFactory which instead of waiting for a newline character to
determine a message has been received, it waits for there to be 0 bytes
left in the buffer. I've tested it by using the original
TextLineCodecFactory class and the exception still occurs so I fairly
sure that the problem doesn't lie in the decoding/encoding of the data.
Majority of the time the GPRS module reports their data successfully,
but on times it does not, the exception above occurs. And the data that
is being sent is always the same (same format, same EOL characters).
When this exception occurs the session is then closed which should not
happen because the module is required to keep its connection
indefinitely to minimize the cost.
Sometimes this exception occurs when theres 50+ clients connected, 90+
clients, or even only 2 or 3 clients connected. It actually seems like
its occuring randomly and I cannot find the cause of this exception.
Hope that all makes sense, if anyone has any ideas please let me know,
it will be much appreciated. If you require any more information let me
know.
Thanks
Conrad