mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 西城 (JIRA) <j...@apache.org>
Subject [jira] [Created] (DIRMINA-1071) ReadFuture.awaitUninterruptibly(20, TimeUnit.SECONDS) is no use
Date Thu, 21 Sep 2017 03:30:00 GMT
西城 created DIRMINA-1071:
---------------------------

             Summary: ReadFuture.awaitUninterruptibly(20, TimeUnit.SECONDS) is no use
                 Key: DIRMINA-1071
                 URL: https://issues.apache.org/jira/browse/DIRMINA-1071
             Project: MINA
          Issue Type: Bug
    Affects Versions: 2.0.16
            Reporter: 西城
         Attachments: N8@`F_%~AEU2MYVTE]IG~IY.png

Describe my problem:i want to send message to client for three times, when the first time
I send to client,but client doesn't answer ,So I try to send again,When the second time I
send,I can receive the answer ,But my core is struck in ReadFuture.awaitUninterruptibly(20,
TimeUnit.SECONDS) until cancel.That is my code,Thanks to answer.

if (future.isWritten()) {
			log.debug("成功发送数据" + protocolMsgVO.toByteString());
			ReadFuture readFuture = session.read();
			BaseProtocolMsgVO msgReceive = null;
			// 等待数据读取完成 等待10s 如果没有返回 关掉连接
			if (readFuture.awaitUninterruptibly(20, TimeUnit.SECONDS)) {
				msgReceive = (BaseProtocolMsgVO) readFuture.getMessage();
			} else {
				session.getConfig().setUseReadOperation(false); // 设置为不需要读取数据
				if(count >= 3){
					log.info("重发超过三次,断开连接");
					// 关掉连接
					session.closeNow();
					throw new BusiException("读取设备响应数据超时");
				}else{
					log.info("重发次数:"+count);
					session.getConfig().setUseReadOperation(false); // 设置为不需要读取数据
					sendCmd(deviceIp, protocolMsgVO, pk_user, openid);
				}
				
			}
			//重置重发次数
			session.setAttribute("count", 0);
			if (readFuture.getException() != null) {
				session.getConfig().setUseReadOperation(false); // 设置为不需要读取数据
				// 关掉连接
				session.closeNow();
				throw new BusiException(readFuture.getException().getMessage());
			}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message