I missed this second thread, but I would add an IoServiceListener to your
SocketConnector (you're using TCP right?) to just make sure you're getting
connections at all.  Also, are you using the WriteFuture after calling
connect to make sure you're connecting?  Something like:

        final ConnectFuture connectFuture =
            connector.connect(serverAddress, handler, config);

        final IoFutureListener futureListener = new IoFutureListener()
            {
            public void operationComplete(final IoFuture ioFuture)
                {
                if (!ioFuture.isReady())
                    {
                    LOG.warn("Future not ready?");
                    return;
                    }
                try
                    {
                    ioSession = ioFuture.getSession();
                    }
                catch (final RuntimeIOException e)
                    {
                    // This seems to get thrown when we can't connect at
all.
                    LOG.warn("Could not connect to server at: {}",
                        serverAddress, e);
                    listener.connectionFailed();
                    return;
                    }
                if (m_ioSession.isConnected())
                    {
                    LOG.debug ("Connected");
                    ioSession.write(msg);
                    }
                else
                    {
                    LOG.debug("Connect failed for: {}", ioSession);
                    listener.connectionFailed();
                    }
                }
            };

        connectFuture.addListener(futureListener);
        connectFuture.join();

That's some of my own code that's been working great for me.  I'd just start
with making sure basic connections are working and then really basic sends,
likely just between a client and a server on localhost.

-Adam


On 8/7/07, Pradheep <[EMAIL PROTECTED]> wrote:
>
>
> I debugged a bit on the scenario, during that time, session.isConnected()
> API
> returns false.
> But it accepts request... ie session.write() doesn't throw any exception .
> btw, does the exception need to be handled explicitly by any chance - I
> have
> not declared
> exception handler for this.
>
> regards,
> Pradheep.
>
>
> mheath wrote:
> >
> > First off, you don't need to synchronize on the iosession.  IoSession
> > is thread safe so you can have multiple threads calling
> > IoSession.write().  I don't think that would be causing the problem
> > your seeing though.
> >
> > To clarify your problem, the server doesn't receive requests from the
> > first client but it does receive requests from the second client?
> > Have you been able to verify the first client is actually sending data
> > to the server?  Could it be a server problem?
> >
> > -Mike
> >
> > On 8/3/07, Pradheep <[EMAIL PROTECTED]> wrote:
> >>
> >> Hi,
> >>
> >> I'm facing an issue when the multiple threads are accessing the session
> >> (IOSession) concurrently. <br>
> >>
> >> ISSUE
> >> When the client is invoked with multiple threads, the client keeps
> >> sending
> >> the requests to but the packets never reach the server. at one point of
> >> time
> >> all the threads are waiting for the resposne ie the client is
> completely
> >> blocked.
> >>
> >> But when a new client connects to it, it works fine, but the previous
> >> client
> >> simply waits for response
> >> (the server prints each request it receives)
> >>
> >> Question Are there any such known issues on MINA or is it problem with
> >> the
> >> way the code operates (pseudo code is given below).
> >>
> >>
> --------------------------------------------------------------------------------------------------------------------------
> >> void sendAndWaitForResponse() {
> >>   synchronized(iosession) {
> >>         Response responseMessage = new Respons();
> >>         iosession.write(message);      // write the bytes in to session
> >>         map.put(requestID,response)  //store the response object in a
> MAP
> >> -
> >> with an id
> >>         responseMessage.wait();
> >>    }
> >> }
> >>
> >> void responseReceived(Response receivedResposne) {
> >>
> >>       Response lockedResponse = map.get(receivedResposne.getID());
> >>       lockedResponse.notify();
> >> }
> >>
> --------------------------------------------------------------------------------------------------------------------------
> >>
> >> Note - It is very much sure that ID generation produces unique key.
> >>
> >> Thanks in advance,
> >> Let me know if you need more information.
> >>
> >> regards,
> >> Pradheep.
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/An-issue-with-multiple-threads.....---Reposted-due-to-formatting-issues-tf4213558s16868.html#a11986763
> >> Sent from the Apache MINA Support Forum mailing list archive at
> >> Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/An-issue-with-multiple-threads.....---Reposted-due-to-formatting-issues-tf4213558s16868.html#a12029927
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Reply via email to