Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

部署至阿里云服务器时出现的问题 #39

Closed
C644753271 opened this issue Apr 11, 2019 · 7 comments
Closed

部署至阿里云服务器时出现的问题 #39

C644753271 opened this issue Apr 11, 2019 · 7 comments

Comments

@C644753271
Copy link

maven打包时,@serverendpoint的host属性如果直接设置阿里云服务器公网ip,无法打包。

当我将host设置为0.0.0.0时,打包正常,客户端也能正常获取到推送的数据,但是会报一个远程主机强迫关闭了一个现有的连接。

2019-04-11 16:11:44.523 [nioEventLoopGroup-3-2] ERROR org.yeauty.pojo.PojoEndpointServer - Unexpected exception:
java.lang.NullPointerException: null
at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.yeauty.pojo.PojoEndpointServer.doOnError(PojoEndpointServer.java:134)
at org.yeauty.standard.HttpServerHandler.exceptionCaught(HttpServerHandler.java:96)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireExceptionCaught(CombinedChannelDuplexHandler.java:426)
at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:87)
at io.netty.channel.CombinedChannelDuplexHandler$1.fireExceptionCaught(CombinedChannelDuplexHandler.java:147)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
at io.netty.channel.CombinedChannelDuplexHandler.exceptionCaught(CombinedChannelDuplexHandler.java:233)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256)
at io.netty.channel.DefaultChannelPipeline$HeadContext.exceptionCaught(DefaultChannelPipeline.java:1401)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264)
at io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:953)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:125)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:174)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Unknown Source)
2019-04-11 16:11:44.807 [nioEventLoopGroup-3-3] ERROR org.yeauty.pojo.PojoEndpointServer - Unexpected exception:
java.io.IOException: 远程主机强迫关闭了一个现有的连接。
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(Unknown Source)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.read(Unknown Source)
at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1108)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Unknown Source)

项目部分附件如下
test.zip

@YeautyYE
Copy link
Owner

若客户端强制关闭,但是服务器还在从这个套接字通道读取数据,服务器会报“java.io.IOException: 远程主机强迫关闭了一个现有的连接。”。导致这种情况出现的原因就是,客户端异常关闭后,服务器的选择器会获取到与客户端套接字对应的套接字通道SelectionKey,并且这个key的兴趣是OP_READ,执行从这个通道读取数据时,客户端已套接字已关闭,所以会出现“java.io.IOException: 远程主机强迫关闭了一个现有的连接”的错误。通常可以忽略IOException
另外,我这边测试设置公网ip进行打包,不会报错.你再尝试下

@woxinfeixiang233
Copy link

我用公网ip设置host:服务器你上启动项目是不报错的,但是我客户端连接用公网ip加端口建立不起连接,然后就是那个ioException 我这边是配置host为0.0.0.0 或者 负载均衡ip 都会一直不停的报ioException

@woxinfeixiang233
Copy link

我设置了公网ip打包进行测试,发现项目启动的时候抛出了一个异常:java.net.BindException: Cannot assign requested address: bind 提示ip地址配置错误 所以建立不了连接:我的公网ip是设置在@serverendpoint(port=8081,host="") host中,所以我不是说很清楚为什么会出现这种情况呢?

@C644753271
Copy link
Author

C644753271 commented Apr 11, 2019

我用公网ip设置host:服务器上启动项目是不报错的,但是我客户端连接用公网ip加端口建立不起连接,然后就是那个ioException 我这边是配置host为0.0.0.0 或者 负载均衡ip 都会一直不停的报ioException

@C644753271
Copy link
Author

你这边能给个联系方式吗?

@woxinfeixiang233
Copy link

woxinfeixiang233 commented Apr 11, 2019 via email

@YeautyYE
Copy link
Owner

你把微信号发我邮箱吧,QQ比较少用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants