java - 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)
解决方案
推荐阅读
- caching - 缓存在我的 VUE JS 应用程序中显示旧的更新图片
- python - 将分类数据转换为虚拟集
- azure-devops - 如何修复从 Azure 数据工厂 V2 到 AzureDevops 的 REST 连接中的“无法从 Rest Source 读取”错误?
- javascript - 带有范围滑块 JS 的马来西亚等值线图
- ios - In-Memory Realm 是否有 Swift 中磁盘持久化 Realm 数据的副本?
- java - Java缓存SSL失败 - 我可以以某种方式刷新这些
- django - 从对象列表中接收相关模型的列表(由外键绑定)。姜戈
- virtualenv - 如何在 Raspberry Pi3 上的 Python3 虚拟环境中安装 PySide2
- java - LibGDX:最大屏幕宽度
- angular - 在spring应用程序中集成angular app,JSP页面[TypeError]