Example usage for io.netty.channel ChannelFuture cause

List of usage examples for io.netty.channel ChannelFuture cause

Introduction

In this page you can find the example usage for io.netty.channel ChannelFuture cause.

Prototype

Throwable cause();

Source Link

Document

Returns the cause of the failed I/O operation if the I/O operation has failed.

Usage

From source file:divconq.api.internal.DownloadHandler.java

License:Open Source License

public Channel allocateChannel(final HyperSession parent, OperationResult or) {
    final AtomicReference<Future<Channel>> sslready = new AtomicReference<>();

    Bootstrap b = new Bootstrap();

    b.group(Hub.instance.getEventLoopGroup()).channel(NioSocketChannel.class)
            .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override//from  w w  w. j  a v a 2 s . co  m
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();

                    if (parent.getInfo().isSecurel()) {
                        SslHandler sh = new SslHandler(parent.getSsl().getClientEngine());
                        sslready.set(sh.handshakeFuture());
                        pipeline.addLast("ssl", sh);
                    }

                    pipeline.addLast("codec", new HttpClientCodec());
                    //pipeline.addLast("decoder", new HttpResponseDecoder());
                    //pipeline.addLast("encoder", new HttpRequestEncoder());

                    pipeline.addLast("handler", DownloadHandler.this);
                }
            });

    or.info("Web Data Client connecting");

    try {
        // must wait here to make sure we don't release connectLock too soon
        // we want chanel init (above) to complete before we try connect again
        ChannelFuture f = b.connect(parent.getInfo().getAddress()).sync();

        if (!f.isSuccess()) {
            or.error(1, "Web Data Client unable to successfully connect: " + f.cause());
        }

        // it has appeared that sometimes we "overshoot" the ssl handshake in code - to prevent
        // that lets wait for the handshake to be done for sure
        if (sslready.get() != null) {
            Future<Channel> sf = sslready.get().sync();

            if (!sf.isSuccess()) {
                or.error(1, "Web Data Client unable to securely connect: " + sf.cause());
            }
        }

        return f.channel();
    } catch (InterruptedException x) {
        or.error(1, "Web Data Client interrupted while connecting: " + x);
    } catch (Exception x) {
        or.error(1, "Web Data Client unable to connect: " + x);
    }

    return null;
}

From source file:divconq.api.internal.UploadPostHandler.java

License:Open Source License

public Channel allocateChannel(final HyperSession parent, OperationResult or) {
    final AtomicReference<Future<Channel>> sslready = new AtomicReference<>();

    Bootstrap b = new Bootstrap();

    b.group(Hub.instance.getEventLoopGroup()).channel(NioSocketChannel.class)
            .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override//from ww w .j  a v  a  2  s .c  o m
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();

                    if (parent.getInfo().isSecurel()) {
                        SslHandler sh = new SslHandler(parent.getSsl().getClientEngine());
                        sslready.set(sh.handshakeFuture());
                        pipeline.addLast("ssl", sh);
                    }

                    pipeline.addLast("codec", new HttpClientCodec());

                    // Remove the following line if you don't want automatic content decompression.
                    //pipeline.addLast("inflater", new HttpContentDecompressor());

                    // to be used since huge file transfer
                    pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());

                    // so we can get the upload response (200 or not)
                    pipeline.addLast("handler", UploadPostHandler.this);
                }
            });

    System.out.println("Web Data Client connecting");

    try {
        // must wait here to make sure we don't release connectLock too soon
        // we want chanel init (above) to complete before we try connect again
        ChannelFuture f = b.connect(parent.getInfo().getAddress()).sync();

        if (!f.isSuccess()) {
            or.error(1, "Web Client unable to successfully connect: " + f.cause());
            System.out.println("Web Client unable to successfully connect: " + f.cause());
        }

        // it has appeared that sometimes we "overshoot" the ssl handshake in code - to prevent
        // that lets wait for the handshake to be done for sure
        if (sslready.get() != null) {
            Future<Channel> sf = sslready.get().sync();

            if (!sf.isSuccess()) {
                or.error(1, "Web Client unable to securely connect: " + sf.cause());
                System.out.println("Web Client unable to securely connect: " + sf.cause());
            }
        }

        return f.channel();
    } catch (InterruptedException x) {
        or.error(1, "Web Client interrupted while connecting: " + x);
        System.out.println("Web Client interrupted while connecting: " + x);
    } catch (Exception x) {
        or.error(1, "Web Client unable to connect: " + x);
        System.out.println("Web Client unable to connect: " + x);
    }

    return null;
}

From source file:divconq.api.internal.UploadPutHandler.java

License:Open Source License

public Channel allocateChannel(final HyperSession parent, OperationResult or) {
    final AtomicReference<Future<Channel>> sslready = new AtomicReference<>();

    Bootstrap b = new Bootstrap();

    b.group(Hub.instance.getEventLoopGroup()).channel(NioSocketChannel.class)
            .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override//from   ww w.  jav  a2s. com
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();

                    if (parent.getInfo().isSecurel()) {
                        SslHandler sh = new SslHandler(parent.getSsl().getClientEngine());
                        sslready.set(sh.handshakeFuture());
                        pipeline.addLast("ssl", sh);
                    }

                    pipeline.addLast("codec", new HttpClientCodec());

                    // so we can get the upload response (200 or not)
                    pipeline.addLast("handler", UploadPutHandler.this);
                }
            });

    or.info("Web Data Client connecting");

    try {
        // must wait here to make sure we don't release connectLock too soon
        // we want chanel init (above) to complete before we try connect again
        ChannelFuture f = b.connect(parent.getInfo().getAddress()).sync();

        if (!f.isSuccess()) {
            or.error(1, "Web Client unable to successfully connect: " + f.cause());
        }

        // it has appeared that sometimes we "overshoot" the ssl handshake in code - to prevent
        // that lets wait for the handshake to be done for sure
        if (sslready.get() != null) {
            Future<Channel> sf = sslready.get().sync();

            if (!sf.isSuccess()) {
                or.error(1, "Web Client unable to securely connect: " + sf.cause());
            }
        }

        return f.channel();
    } catch (InterruptedException x) {
        or.error(1, "Web Client interrupted while connecting: " + x);
    } catch (Exception x) {
        or.error(1, "Web Client unable to connect: " + x);
    }

    return null;
}

From source file:divconq.bus.Bus.java

License:Open Source License

public void connect() {
    // never try to connect until init has run
    if (Hub.instance.isStopping())
        return;/*w w w .j a va 2  s .co  m*/

    // if connect method is already running then skip - it will try again later 
    if (!this.connectLock.tryLock())
        return;

    try {
        // ==========================================================================
        //   Add client connections when not enough
        // ==========================================================================

        for (final SocketInfo info : this.connectors.values()) {
            HubRouter router = this.allocateOrGetHub(info.getHubId(), info.isGateway());

            if (router.isLocal())
                continue;

            // -------------------------------------------------
            // message port
            // -------------------------------------------------
            int conncount = router.getCountSessions(info);

            // add a coonection only once per call to connect (should be between 2 - 15 seconds between calls)
            if (conncount < info.getCount()) {
                Bootstrap b = new Bootstrap();

                b.group(this.getEventLoopGroup()).channel(NioSocketChannel.class)
                        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 250)
                        .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
                        .handler(new ChannelInitializer<SocketChannel>() {
                            @Override
                            public void initChannel(SocketChannel ch) throws Exception {
                                ChannelPipeline pipeline = ch.pipeline();

                                if (info.isUseSsl())
                                    pipeline.addLast("ssl",
                                            new SslHandler(SslContextFactory.getClientEngine()));

                                pipeline.addLast("http-codec", new HttpClientCodec());
                                pipeline.addLast("aggregator", new HttpObjectAggregator(8192)); // TODO is this too small?

                                pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(60)); // TODO config
                                pipeline.addLast("writeTimeoutHandler", new WriteTimeoutHandler(30)); // TODO config

                                pipeline.addLast("ws-handler", new ClientHandler(info));
                            }
                        });

                Logger.debug("dcBus Client connecting");

                try {
                    // must wait here to make sure we don't release connectLock too soon
                    // we want channel init (above) to complete before we try connect again
                    b.connect(info.getAddress()).sync();
                } catch (InterruptedException x) {
                    Logger.warn("dcBus Client interrupted while connecting: " + x);
                } catch (Exception x) {
                    Logger.debug("dcBus Client unable to connect: " + x);
                }
            }

            // -------------------------------------------------
            // stream port
            // -------------------------------------------------
            conncount = router.getCountStreamSessions(info);

            // add a coonection only once per call to connect (should be between 2 - 15 seconds between calls)
            if (conncount < info.getStreamCount()) {
                Bootstrap b = new Bootstrap();

                b.group(this.getEventLoopGroup()).channel(NioSocketChannel.class)
                        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 250)
                        .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
                        .handler(new ChannelInitializer<SocketChannel>() {
                            @Override
                            public void initChannel(SocketChannel ch) throws Exception {
                                ChannelPipeline pipeline = ch.pipeline();

                                if (info.isUseSsl())
                                    pipeline.addLast("ssl",
                                            new SslHandler(SslContextFactory.getClientEngine()));

                                // TODO consider compression

                                pipeline.addLast("decoder", new StreamDecoder());
                                pipeline.addLast("encoder", new StreamEncoder());

                                pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(60)); // TODO config
                                pipeline.addLast("writeTimeoutHandler", new WriteTimeoutHandler(30)); // TODO config

                                pipeline.addLast("handler", new StreamHandler(info, false));
                            }
                        });

                Logger.debug("dcBus Client stream connecting");

                try {
                    // must wait here to make sure we don't release connectLock too soon
                    // we want chanel init (above) to complete before we try connect again
                    b.connect(info.getStreamAddress()).addListener(new GenericFutureListener<ChannelFuture>() {
                        @Override
                        public void operationComplete(ChannelFuture cf) throws Exception {
                            if (!cf.isSuccess()) {
                                Logger.debug("dcBus Stream unable to connect: " + cf.cause());
                                return;
                            }

                            // client starts the HELLO thing once connected!
                            StreamMessage icmd = Hub.instance.getBus().getLocalHub()
                                    .buildStreamHello(info.getHubId());
                            cf.channel().writeAndFlush(icmd);
                        }
                    }).sync();
                } catch (InterruptedException x) {
                    Logger.warn("dcBus Client stream interrupted while connecting: " + x);
                } catch (Exception x) {
                    Logger.debug("dcBus Client stream unable to connect: " + x);
                }
            }
        }

        // ==========================================================================
        //   Add server binding when missing
        // ==========================================================================

        for (final SocketInfo info : this.listeners) {
            // only if not currently bound
            if (this.activelisteners.containsKey(info))
                continue;

            // -------------------------------------------------
            // message port
            // -------------------------------------------------
            ServerBootstrap b = new ServerBootstrap();

            b.group(this.getEventLoopGroup()).channel(NioServerSocketChannel.class)
                    .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
                    //.option(ChannelOption.SO_BACKLOG, 125)         // this is probably not needed but serves as note to research
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ChannelPipeline pipeline = ch.pipeline();

                            if (info.isUseSsl())
                                pipeline.addLast("ssl", new SslHandler(SslContextFactory.getServerEngine()));

                            pipeline.addLast("codec-http", new HttpServerCodec());
                            pipeline.addLast("aggregator", new HttpObjectAggregator(65536));

                            pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(60)); // TODO config
                            pipeline.addLast("writeTimeoutHandler", new WriteTimeoutHandler(30)); // TODO config

                            pipeline.addLast("handler", new ServerHandler(info));
                        }
                    });

            try {
                // must wait here, both to keep the activelisteners listeners up to date
                // but also to make sure we don't release connectLock too soon
                ChannelFuture bfuture = b.bind(info.getAddress()).sync();

                if (bfuture.isSuccess()) {
                    Logger.info("dcBus Message Server listening - now listening for dcMessages on TCP port "
                            + info.getPort());
                    this.activelisteners.put(info, bfuture.channel());
                } else
                    Logger.error("dcBus Server unable to bind: " + bfuture.cause());
            } catch (InterruptedException x) {
                Logger.warn("dcBus Server interrupted while binding: " + x);
            } catch (Exception x) {
                Logger.error("dcBus Server unable to bind: " + x);
            }

            // -------------------------------------------------
            // stream port
            // -------------------------------------------------
            b = new ServerBootstrap();

            b.group(this.getEventLoopGroup()).channel(NioServerSocketChannel.class)
                    .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
                    //.option(ChannelOption.SO_BACKLOG, 125)         // this is probably not needed but serves as note to research
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ChannelPipeline pipeline = ch.pipeline();

                            if (info.isUseSsl())
                                pipeline.addLast("ssl", new SslHandler(SslContextFactory.getServerEngine()));

                            // TODO consider compression

                            pipeline.addLast("decoder", new StreamDecoder());
                            pipeline.addLast("encoder", new StreamEncoder());

                            pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(60)); // TODO config
                            pipeline.addLast("writeTimeoutHandler", new WriteTimeoutHandler(30)); // TODO config

                            pipeline.addLast("handler", new StreamHandler(info, true));
                        }
                    });

            try {
                // must wait here, both to keep the activelisteners listeners up to date
                // but also to make sure we don't release connectLock too soon
                ChannelFuture bfuture = b.bind(info.getStreamAddress()).sync();

                if (bfuture.isSuccess()) {
                    Logger.info("dcBus Stream Server listening - now listening for dcStreams on TCP port "
                            + info.getPort());
                    this.activestreamlisteners.put(info, bfuture.channel());
                } else
                    Logger.error("dcBus Stream Server unable to bind: " + bfuture.cause());
            } catch (InterruptedException x) {
                Logger.warn("dcBus Stream Server interrupted while binding: " + x);
            } catch (Exception x) {
                Logger.error("dcBus Stream Server unable to bind: " + x);
            }
        }

        // ==========================================================================
        //   Remove server binding as needed
        // ==========================================================================

        for (final SocketInfo info : this.activelisteners.keySet()) {
            // all is well if in the listeners list
            if (this.listeners.contains(info))
                continue;

            // otherwise we don't want to bind anymore
            this.stopSocketListener(info);
        }
    } finally {
        this.connectLock.unlock();
    }
}

From source file:divconq.bus.Bus.java

License:Open Source License

protected void stopSocketListener(SocketInfo info) {
    // tear down message port
    Channel ch = this.activelisteners.remove(info);

    try {// w  ww  .  j av a 2  s.c  o  m
        // must wait here, both to keep the activelisteners listeners up to date
        // but also to make sure we don't release connectLock too soon
        ChannelFuture bfuture = ch.close().sync();

        if (bfuture.isSuccess())
            System.out.println("dcBus Server unbound");
        else
            System.out.println("dcBus Server unable to unbind: " + bfuture.cause());
    } catch (InterruptedException x) {
        System.out.println("dcBus Server unable to unbind: " + x);
    }

    // tear down stream port
    ch = this.activestreamlisteners.remove(info);

    try {
        if (ch != null) {
            ChannelFuture bfuture = ch.close().sync();

            if (bfuture.isSuccess())
                System.out.println("dcBus Stream Server unbound");
            else
                System.out.println("dcBus Stream Server unable to unbind: " + bfuture.cause());
        } else
            System.out.println("dcBus Stream Server missing channel");
    } catch (InterruptedException x) {
        System.out.println("dcBus Stream Server unable to unbind: " + x);
    }
}

From source file:divconq.ctp.net.CtpServices.java

License:Open Source License

public void connect() {
    // never try to connect until init has run
    if (Hub.instance.isStopping())
        return;/*from  w w w .j  a  va2  s.  c o  m*/

    // if connect method is already running then skip - it will try again later 
    if (!this.connectLock.tryLock())
        return;

    try {
        // ==========================================================================
        //   Add server binding when missing
        // ==========================================================================

        for (SocketInfo info : this.listeners) {
            // only if not currently bound
            if (this.activelisteners.containsKey(info))
                continue;

            // -------------------------------------------------
            // stream port
            // -------------------------------------------------
            ServerBootstrap b = new ServerBootstrap().group(Hub.instance.getEventLoopGroup())
                    .channel(NioServerSocketChannel.class)
                    .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
                    //.option(ChannelOption.SO_BACKLOG, 125)         // this is probably not needed but serves as note to research
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ChannelPipeline pipeline = ch.pipeline();

                            if (info.isUseSsl())
                                pipeline.addLast("ssl", new SslHandler(SslContextFactory.getServerEngine())); // TODO this should be the external SSL not the BUS one 

                            pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(60)); // TODO config
                            pipeline.addLast("writeTimeoutHandler", new WriteTimeoutHandler(45)); // TODO config

                            //pipeline.addLast("logger", new LoggingHandler(LogLevel.INFO));

                            // start as guest until authenticated
                            CtpAdapter adapter = new CtpAdapter(OperationContext.allocateGuest());
                            adapter.setHandler(new CtpsHandler());

                            pipeline.addLast("ctp", new CtpHandler(adapter, true));
                        }
                    });

            try {
                // must wait here, both to keep the activelisteners listeners up to date
                // and also to make sure we don't release connectLock too soon
                ChannelFuture bfuture = b.bind(info.getAddress()).sync();

                if (bfuture.isSuccess()) {
                    Logger.info("dcCtp Server listening");
                    this.activelisteners.put(info, bfuture.channel());
                } else
                    Logger.error("dcCtp Server unable to bind: " + bfuture.cause());
            } catch (InterruptedException x) {
                Logger.warn("dcCtp Server interrupted while binding: " + x);
            } catch (Exception x) {
                Logger.error("dcCtp Server unable to bind: " + x);
            }
        }

        // ==========================================================================
        //   Remove server binding as needed
        // ==========================================================================

        for (final SocketInfo info : this.activelisteners.keySet()) {
            // all is well if in the listeners list
            if (this.listeners.contains(info))
                continue;

            // otherwise we don't want to bind anymore
            this.stopSocketListener(info);
        }
    } finally {
        this.connectLock.unlock();
    }
}

From source file:divconq.ctp.net.CtpServices.java

License:Open Source License

protected void stopSocketListener(SocketInfo info) {
    // tear down message port
    Channel ch = this.activelisteners.remove(info);

    try {//from   ww  w.  j  a v a 2 s  .  co m
        // must wait here, both to keep the activelisteners listeners up to date
        // but also to make sure we don't release connectLock too soon
        ChannelFuture bfuture = ch.close().sync();

        if (bfuture.isSuccess())
            System.out.println("dcCtp Server unbound");
        else
            System.out.println("dcCtp Server unable to unbind: " + bfuture.cause());
    } catch (InterruptedException x) {
        System.out.println("dcCtp Server unable to unbind: " + x);
    }
}

From source file:divconq.ctp.stream.CtpStreamDest.java

License:Open Source License

@Override
public void operationComplete(ChannelFuture future) throws Exception {
    OperationContext.set(this.ctx);

    TaskRun trun = this.ctx.getTaskRun();

    if (trun == null) {
        System.out.println("Error - stream task missing RUN");
    } else if (future.isSuccess()) {
        if (this.finalFlag)
            trun.complete();/*from  ww w  . jav a2  s .c  om*/
        else
            trun.resume();
    } else {
        trun.kill("ERROR sending - DONE sending!  " + future.cause());
    }
}

From source file:divconq.web.WebModule.java

License:Open Source License

public void goOnline() {
    this.listenlock.lock();

    try {/*from w  w w  . ja  v  a 2  s .  c om*/
        // don't try if already in online mode
        if (this.activelisteners.size() > 0)
            return;

        // typically we should have an extension, unless we are supporting RPC only
        // TODO if (WebSiteManager.instance.getDefaultExtension() == null) 
        //   log.warn(0, "No default extension for web server");

        for (final XElement httpconfig : this.config.selectAll("HttpListener")) {
            final boolean secure = "True".equals(httpconfig.getAttribute("Secure"));
            int httpport = (int) StringUtil.parseInt(httpconfig.getAttribute("Port"), secure ? 443 : 80);

            // -------------------------------------------------
            // message port
            // -------------------------------------------------
            ServerBootstrap b = new ServerBootstrap();

            // TODO consider using shared EventLoopGroup
            // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#25.0

            b.group(Hub.instance.getEventLoopGroup()).channel(NioServerSocketChannel.class)
                    .option(ChannelOption.ALLOCATOR, Hub.instance.getBufferAllocator())
                    //.option(ChannelOption.SO_BACKLOG, 125)         // this is probably not needed but serves as note to research
                    .option(ChannelOption.TCP_NODELAY, true)
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ChannelPipeline pipeline = ch.pipeline();

                            if (secure) {
                                SniHandler ssl = new SniHandler(WebModule.this.siteman);

                                //SslHandler ssl = new SslHandler(WebModule.this.siteman.findSslContextFactory("root").getServerEngine()); 

                                pipeline.addLast("ssl", ssl);
                            }

                            //pipeline.addLast("codec-http", new HttpServerCodec());
                            //pipeline.addLast("aggregator", new HttpObjectAggregator(65536));

                            pipeline.addLast("decoder", new HttpRequestDecoder(4096, 8192, 262144));
                            pipeline.addLast("encoder", new HttpResponseEncoder());

                            pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());

                            // TODO maybe - but currently we selectively compress files which is more efficient
                            // this can also be a cached & compressed response that way
                            //pipeline.addLast("deflater", new HttpContentCompressor());

                            pipeline.addLast("handler", new ServerHandler(httpconfig, WebModule.this.siteman));
                        }
                    });

            try {
                // must wait here, both to keep the activelisteners listeners up to date
                // but also to make sure we don't release connectLock too soon
                ChannelFuture bfuture = b.bind(httpport).sync();

                if (bfuture.isSuccess()) {
                    Logger.info("Web Server listening - now listening for HTTP on TCP port " + httpport);
                    this.activelisteners.put(httpport, bfuture.channel());
                } else
                    Logger.error("Web Server unable to bind: " + bfuture.cause());
            } catch (InterruptedException x) {
                Logger.error("Web Server interrupted while binding: " + x);
            } catch (Exception x) {
                Logger.error("Web Server errored while binding: " + x);
            }
        }
    } finally {
        this.listenlock.unlock();
    }

    this.siteman.online();

    //for (IWebExtension ext : WebSiteManager.instance.extensions.values())
    //   ext.online();
}

From source file:divconq.web.WebModule.java

License:Open Source License

public void goOffline() {
    this.listenlock.lock();

    try {/*  ww  w  .  jav a 2 s  . c  o m*/
        // we don't want to listen anymore
        for (final Integer port : this.activelisteners.keySet()) {
            // tear down message port
            Channel ch = this.activelisteners.remove(port);

            try {
                // must wait here, both to keep the activelisteners listeners up to date
                // but also to make sure we don't release connectLock too soon
                ChannelFuture bfuture = ch.close().sync();

                if (bfuture.isSuccess())
                    Logger.info("Web Server unbound");
                else
                    Logger.error("Web Server unable to unbind: " + bfuture.cause());
            } catch (InterruptedException x) {
                Logger.error("Web Server unable to unbind: " + x);
            }
        }
    } finally {
        this.listenlock.unlock();
    }
}