ReadFuture对象无法读取消息

时间:2015-11-19 12:30:38

标签: java

我正在使用Web应用程序A,它使用IoSession将请求发送到另一个应用程序B,如下所示。 B是一个独立的Java应用程序服务器 侦听指定端口并使用NioSocketAcceptor类创建creatsocket。

以下是客户端代码:

session.write(dom);
try {
                // Read the message received here
                ReadFuture future = session.read();
                // Wait until a message is received.
                future.await(15000);

                message = future.getMessage();
            } catch (InterruptedException e) {
                logger.error("Could not receive the response from Core: ", e);
            } finally {
                // Release the session used
                try {
                    //releasing connection here
                } catch (ConnectionException e) {
                    logger.error("Could not release the Connection used: ", e);
                }
            }

在服务器端,我使用下面的代码将响应写回客户端。

// doc is an object for org.w3c.dom.Document class and session is an object of IoSession class.
session.write(doc); 

除少数情况外,代码工作正常。正如所观察到的,主要是在负载条件下,客户端无法从会话中读取消息,而根据服务器端日志,响应已经生成,并且在将doc对象写入会话时没有异常/错误。

我无法在这里找到问题的根本原因。一直在研究相同但没有一个问题陈述符合这一点。我也尝试过使用没有出现任何死锁的线程转储。请帮忙。

0 个答案:

没有答案
相关问题