首页 > 解决方案 > Jpos java.net.SocketException

问题描述

我编写了一个基本的 jpos 客户端应用程序,它部署在 tomcat 上,它将 8583 条消息发送到 jpos 服务器。jpos 服务器实现已经工作了很长时间,并且有其他客户端连接到它。我编写的客户端 jpos 应用程序由休息端点触发,并且在串行执行请求时工作正常。当通过运行多个线程增加负载时,我在日志中看到以下异常。知道在这种情况下会发生什么吗?

代码

class JposClient{

private CSChannel csChannel;

public ISOMsg send(ISOMsg request){
ISOMsg response
csChannel=getCSChannel();
csChannel.connect();
jposChannel.send(request);
do {
    response = jposChannel.receive();
    }while(response.getMTI().startsWith("08"));

}

return response;

}

private CSChannel getCSChannel() throws IOException {
    
        if(csChannel!=null){
return csChannel;
}
        try {
            csChannel = new CSChannel();
            Configuration configuration = new SimpleConfiguration();
            configuration.put("keep-alive", "true");
            configuration.put("expect-keep-alive", "true");
            configuration.put("host", "127.0.0.1");
            configuration.put("port", String.valueOf(5456));
            csChannel.setConfiguration(configuration);
            csChannel.setPackager(new GenericPackager(
                "packager.xml"););
        } catch (ISOException e) {
            e.printStackTrace();
        }
        return csChannel;
    }

}

日志

java.net.SocketException: Socket is closed
        at java.net.Socket.getInputStream(Socket.java:921)
        at org.jpos.iso.BaseChannel.connect(BaseChannel.java:280)
        at org.jpos.iso.BaseChannel.connect(BaseChannel.java:414)
        at org.jpos.iso.BaseChannel.reconnect(BaseChannel.java:845)


java.io.EOFException: null
        at java.io.DataInputStream.readFully(DataInputStream.java:197)
        at org.jpos.iso.channel.CSChannel.getMessageLength(CSChannel.java:97)
        at org.jpos.iso.BaseChannel.receive(BaseChannel.java:712)

标签: javasocketsjpos

解决方案


推荐阅读