kpavlov / jreactive-8583

Kotlin/Java Client & Server for ISO8583 & Netty
Apache License 2.0
320 stars 146 forks source link

Connection Reset By Peer #152

Open shadowray0 opened 1 year ago

shadowray0 commented 1 year ago

Hi All,

I have created a ISO8583 client which is connecting to a JPOS Server. Server accepts all requests with a 21 length header so I have extended the messagefactory to send the correct header length in parseMessage function.

Now whenever I try to connect to server, client.isConnected() method returns true but then instantly I start getting below error continuously in logs. Any help would be greatly appreciated

2022-10-13 07:59:12,068 [nioEventLoopGroup-13-1] traceId:[] WARN  i.n.channel.DefaultChannelPipeline#1152 -> An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.io.IOException: Connection reset by peer
    at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
    at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:233)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
    at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358)
    at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1133)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)

Sometimes in between I also get this error


io.netty.handler.codec.DecoderException: java.text.ParseException: ISO8583 MessageFactory has no parsing guide for message type fffffff0 [ISO8583-1993001000000� 
                                                                                                                                                                 YY 1"#
]```
kpavlov commented 1 year ago

It looks like the server does not understand a message and terminates a connection at some point. You may try to test message encoder in isolation: encode your message to byte array and try to decode it using JPOS decoder. I hope it would help. Regarding ParseException - I guess that message decoding did not went well and message type was wrongly recognised.

Could you please contribute by adding your test? I could not help you without having a test to reproduce.