问题描述
需求:mina开发客户端,上传文件,发送请求报文后,服务端返回“0000”确认,客户端接收“0000”之后分包传输文件,文件传输完成后,服务端返回响应报文DefaultIoFilterChainBuilderchain=connector.getFilterChain();ProtocolCodecFilterfilter=newProtocolCodecFilter(newABCClientCodecFactory("UTF-8"));chain.addLast("objectFilter",filter);SocketSessionConfigcfg=connector.getSessionConfig();cfg.setUseReadOperation(true);ConnectFuturecf=connector.connect(newInetSocketAddress("localhost",5678));cf.awaitUninterruptibly();session=cf.getSession();session.write(reqXml);//发送文件上传的请求ReadFuturereadFuture=session.read();ObjectrtnXml=readFuture.awaitUninterruptibly().getMessage();while("0000".equals(rtnXml)){buffer.put(file);buffer.flip();session.write(buffer);//传输文件rtnXml=readFuture.awaitUninterruptibly().getMessage();}但是session.read()之后发现session已经是null,已经不能再次向服务器端发送信息了,这是为什么呢?没执行session.close(true)啊,这种情况要怎么解决呢?