1
我寫在一個servlet一個網狀服務器。每次servlet被容器初始化時,它都會啓動netty服務器。但我總是得到綁定異常,說「地址已經在使用:綁定」。我得到的例外如下所示。的Netty服務器的BindException
java.net.BindException: Address already in use: bindAddress already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:101)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:474)
at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:995)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind0(DefaultChannelHandlerContext.java:488)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:474)
at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:468)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:837)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:193)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:321)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:366)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Unknown Source)
那麼,有沒有人可以幫助擺脫這個問題。提前致謝!
它已經運行,或別的東西,在同一端口上。 – EJP
你是如何開始和停止netty?除非你已經有其他的東西在使用那個端口,這是因爲試圖運行你的netty服務器兩次。 – jlunavtgrad