Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-777

IoSessionConfig.setUseReadOperation(true) doesn't seem to work

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-RC1
    • Fix Version/s: 2.0.8
    • Component/s: Core
    • Environment:
      Mac OS X 10.6.2, Java 1.6, Android SDK

      Description

      I'm attempting to perform a synchronous write/read in a demux-based client application with MINA 2.0 RC1, but it seems to get stuck. Here is my code:

      public boolean login(final String username, final String password) {
          // block inbound messages
          session.getConfig().setUseReadOperation(true);
      
          // send the login request
          final LoginRequest loginRequest = new LoginRequest(username, password);
          final WriteFuture writeFuture = session.write(loginRequest);
          writeFuture.awaitUninterruptibly();
      
          if (writeFuture.getException() != null) {
              session.getConfig().setUseReadOperation(false);
              return false;
          }
      
          // retrieve the login response
          final ReadFuture readFuture = session.read();
          readFuture.awaitUninterruptibly();
      
          if (readFuture.getException() != null) {
              session.getConfig().setUseReadOperation(false);
              return false;
          }
      
          // stop blocking inbound messages
          session.getConfig().setUseReadOperation(false);
      
          // determine if the login info provided was valid
          final LoginResponse loginResponse = (LoginResponse)readFuture.getMessage();
          return loginResponse.getSuccess();
      }
      

      I can see on the server side that the LoginRequest object is retrieved, and a LoginResponse message is sent. On the client side, the DemuxingProtocolCodecFactory receives the response, but after throwing in some logging, I can see that the client gets stuck on the call to `readFuture.awaitUninterruptibly() `.

      I can't for the life of me figure out why it is stuck here based upon my own code. I properly set the read operation to true on the session config, meaning that messages should be blocked. However, it seems as if the message no longer exists by time I try to read response messages synchronously.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mhuggins Matt Huggins
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: