NutzCN Logo
问答 在nutzwk里启动netty服务器失败
发布于 2294天前 作者 bb3239 2115 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

想用netty做websocket通信,启动方法为WebSocketServer.run(); 但是在nutzwk的Setup的init方法里面执行WebSocketServer.run()时,websocket服务能启动,也能正常与客户端通信,但是nutzwk启动不了,没有报错,不知道什么原因。

public static void run(){
        int port=8888;
        final WebSocketServer endpoint = new WebSocketServer();
        ChannelFuture future = endpoint.start(new InetSocketAddress(port));
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                endpoint.destroy();
            }
        });
        future.channel().closeFuture().syncUninterruptibly();
    }
[DEBUG] 2018-09-11 19:00:43,000 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM sys_plugin  WHERE disabled=?
    |     1 |
    |-------|
    | false |
  For example:> "SELECT * FROM sys_plugin  WHERE disabled=false"
[DEBUG] 2018-09-11 19:00:43,005 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'cacheManager'<class net.sf.ehcache.CacheManager>
[DEBUG] 2018-09-11 19:00:43,005 cn.wizzer.app.web.commons.core.Setup.init(Setup.java:106) - Ehcache CacheManager = nutzwk
[DEBUG] 2018-09-11 19:00:43,031 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - Using SLF4J as the default logging framework
[DEBUG] 2018-09-11 19:00:43,057 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - Platform: Windows
[DEBUG] 2018-09-11 19:00:43,058 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - Java version: 8
[DEBUG] 2018-09-11 19:00:43,058 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.noUnsafe: false
[DEBUG] 2018-09-11 19:00:43,062 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - java.nio.ByteBuffer.cleaner: available
[DEBUG] 2018-09-11 19:00:43,062 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - java.nio.Buffer.address: available
[DEBUG] 2018-09-11 19:00:43,063 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - sun.misc.Unsafe.theUnsafe: available
[DEBUG] 2018-09-11 19:00:43,064 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - sun.misc.Unsafe.copyMemory: available
[DEBUG] 2018-09-11 19:00:43,064 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - java.nio.Bits.unaligned: true
[DEBUG] 2018-09-11 19:00:43,064 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - sun.misc.Unsafe: available
[DEBUG] 2018-09-11 19:00:43,065 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.noJavassist: false
[DEBUG] 2018-09-11 19:00:43,068 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - Javassist: unavailable
[DEBUG] 2018-09-11 19:00:43,068 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes.  Please check the configuration for better performance.
[DEBUG] 2018-09-11 19:00:43,069 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.noPreferDirect: false
[DEBUG] 2018-09-11 19:00:43,077 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.eventLoopThreads: 8
[DEBUG] 2018-09-11 19:00:43,092 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.noKeySetOptimization: false
[DEBUG] 2018-09-11 19:00:43,093 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.selectorAutoRebuildThreshold: 512
[DEBUG] 2018-09-11 19:00:43,725 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.machineId: 44:39:c4:4f:c6:3c:00:00 (auto-detected)
[DEBUG] 2018-09-11 19:00:43,729 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.processId: 10612 (auto-detected)
[DEBUG] 2018-09-11 19:00:43,736 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - -Dio.netty.initialSeedUniquifier: 0xc60ca669bdc05005
[DEBUG] 2018-09-11 19:00:43,765 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - -Dio.netty.threadLocalDirectBufferSize: 65536
[DEBUG] 2018-09-11 19:00:43,897 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - Loopback interface: Software Loopback Interface 1
[DEBUG] 2018-09-11 19:00:43,898 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - Loopback address: /127.0.0.1 (primary)
[DEBUG] 2018-09-11 19:00:43,898 io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:76) - Loopback address: /0:0:0:0:0:0:0:1
2 回复

开新线程,不能阻塞主线程

@wendal 解决了,谢谢

添加回复
请先登陆
回到顶部