client有如下伪代码:
try{
Socket ss = new Socket();
ss.connect(new InetSocketAddress(127.0.0.1, TCPServer.LISTEN_PORT), 4000);
ss.setSoTimeout(5000);
//dosomthing
InputStream is = ss.getInputStrean();
log.info("read start time:" + System.currentTimeMillis())
int r = is.read(....);
log.info("read start time:" + System.currentTimeMillis())
} catch(Exception e){
log.info("throw exception time:" + System.currentTimeMillis());
}
上面这样的逻辑,ss.setSoTimeout(5000);
把读超时设置为5000
ms,可经过测试read
的时间也不过才619
ms 就抛出了如题的异常?
这是服务端是同步通知,时间过长,把服务端修改成异步的即可