Hmnn...makes sense now.  I catch the RuntimeIOs, but I don't see why you'd
want to keep looping.  Doesn't the RuntimeIOException simply indicate the
server didn't respond within the default timeout or some other legitimate
reason for a failure?  Why would you want to hammer the server like that?

On 9/10/07, mat <[EMAIL PROTECTED]> wrote:
>
> protected void connect() {
>   Logger.info(" connecting " + ip + ":" + port);
>   while (true) {
>    try {
>     ConnectFuture future = connector.connect(new InetSocketAddress(ip,
> port), handler, config);
>     future.join();
>     session = future.getSession();
>     Logger.info(" connected");
>     break;
>    }
>    catch( RuntimeIOException e ) {
>     Logger.info(" failed to connect " + ip + ":" + port);
>    }
>
>    try {
>     Logger.info(" reconnecting " + ip + ":" + port);
>     Thread.sleep(10000);
>    }
>    catch (InterruptedException e) {
>     e.printStackTrace();
>    }
>   }
> }
>
>
> On 9/11/07, Adam Fisk <[EMAIL PROTECTED]> wrote:
> >
> > So we should not be catching the RuntimeIOException, is that right?
> >
> > One way around all of this would be to use the
> > InetAddress.isReachablemethod before trying to connect.  I've found
> > that to be useful in my own
> > code.
> >
> > -Adam
> >
> >
> > On 9/8/07, mat <[EMAIL PROTECTED]> wrote:
> > >
> > > 1)  Please don't double post the same thread. Thanks.
> > > 2)  Did you catch RuntimeIOException after ConnectFuture future =
> > > connector.connect()? The reconnect in a infinite loop without
> > Thread.sleep
> > > ()
> > > normally causes 100% CPU usage.
> > >
> > >
> > > On 9/8/07, YoungJoon, Chun <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello.
> > > >
> > > >
> > > >
> > > > I'm using mina in my server application and the server also uses
> > > > SocketConnector to connect to client in some cases. Sometimes my
> > server
> > > > uses
> > > > CPU up to 100% and I found out that
> > > >
> > > > when SocketConnector connects to an address which is not reachable
> > > > (machine
> > > > is off), it just use up all cpu resource after some time trying to
> > > connect
> > > > (eg. 30 seconds).
> > > >
> > > >
> > > >
> > > > A simple test application that uses SocketConnector also has same
> > > problem.
> > > > 1
> > > > connection uses 50% cpu and
> > > >
> > > > 2 or more connections more cpu %.
> > > >
> > > >
> > > >
> > > > The weird thing is even though machine is off and the address is not
> > > > reachable (no route to host with telnet), connection handler's
> > (instance
> > > > of
> > > > SingleSessionIoHandler) sessionOpened() method is called, though no
> > > > further
> > > > progress. And setConnectTimeout() does not work and ConnectFuture is
> > not
> > > > getting notified as well.
> > > >
> > > >
> > > >
> > > > My debugging shows SocketIoProcessor thread seems to be the cause.
> > > > Couldn't
> > > > figure out the detail yet.
> > > >
> > > > Anyone is having the same problem with me?
> > > >
> > > >
> > > >
> > > > I'm using mina 2.0 trunk (from maven repository) and java 1.6u2,
> > Windows
> > > > XP
> > > > SP2.
> > > >
> > > > Thanks.
> > > >
> > > >
> > > >
> > > >
> > >
> >
>

Reply via email to