没有互联网接入的Websocket连接(Ubuntu)
我有一个Spring Boot应用程序,它实现了一个Websocket服务器(SockJS)。没有互联网接入的Websocket连接(Ubuntu)
只要主机应用程序的Ubuntu机器具有Internet访问权限,我就可以将客户机连接到本地网络上的该服务器。
2016-10-27 11:22:20.802 DEBUG 9390 --- [nio-8085-exec-9] o.a.coyote.http11.Http11NioProtocol : Socket: [[email protected]:[email protected]:java.nio.channels.SocketChannel[connected local=/192.168.1.104:8085 remote=/192.168.1.106:51946]], Status in: [OPEN_READ], State out: [CLOSED]
2016-10-27 11:22:20.849 DEBUG 9390 --- [io-8085-exec-10] d.f.util.ConnectivityCheckUtil : Local network interface found: wlp2s0 192.168.1.104 2016-10-27 11:22:20.850 DEBUG 9390 --- [io-8085-exec-10] d.f.util.ConnectivityCheckUtil : Your ip is: 192.168.1.104
2016-10-27 11:22:20.850 DEBUG 9390 --- [io-8085-exec-10] d.f.i.v.b.i.w.s.BrokerWebsocketHandler : Connected ... t0obkpdo 2016-10-27 11:22:20.851 INFO 9390 --- [io-8085-exec-10] d.f.i.v.b.i.w.s.BrokerWebsocketHandler : websocketTextmessagesize = 1000000
2016-10-27 11:22:20.852 DEBUG 9390 --- [io-8085-exec-10] o.a.coyote.http11.Http11NioProtocol : Socket: [[email protected]:[email protected]:java.nio.channels.SocketChannel[connected local=192.168.1.104/192.168.1.104:8085 remote=/192.168.1.106:51947]], Status in: [OPEN_READ], State out: [UPGRADING]
2016-10-27 11:22:20.852 DEBUG 9390 --- [io-8085-exec-10] o.a.coyote.http11.Http11NioProtocol : Socket: [[email protected]:[email protected]:java.nio.channels.SocketChannel[connected local=192.168.1.104/192.168.1.104:8085 remote=/192.168.1.106:51947]], Status in: [OPEN_READ], State out: [UPGRADED]
我拉我的WAN网络路由器上插入的那一刻,服务器会删除所有WS连接,也不允许新的。客户端将报告错误代码2000'All transports failed'。正如我在插上WAN电缆背部和路由器再次拥有互联网接入,WS连接,重新开始工作一旦
2016-10-27 11:18:38.380 DEBUG 9390 --- [nio-8085-exec-1] o.a.coyote.http11.Http11NioProtocol : Socket: [[email protected]:[email protected]:java.nio.channels.SocketChannel[closed]], Status in: [OPEN_READ], State out: [CLOSED]
2016-10-27 11:18:51.396 DEBUG 9390 --- [nio-8085-exec-2] o.a.coyote.http11.Http11NioProtocol : Socket: [[email protected]:[email protected]:java.nio.channels.SocketChannel[connected local=/192.168.1.104:8085 remote=/192.168.1.106:51692]], Status in: [OPEN_READ], State out: [CLOSED]
2016-10-27 11:19:01.437 DEBUG 9390 --- [nio-8085-exec-6] o.a.coyote.http11.Http11NioProtocol : Socket: [[email protected]:[email protected]:java.nio.channels.SocketChannel[connected local=192.168.1.104/192.168.1.104:8085 remote=/192.168.1.106:51693]], Status in: [OPEN_READ], State out: [CLOSED]
2016-10-27 11:19:02.141 DEBUG 9390 --- [nio-8085-exec-3] d.f.util.ConnectivityCheckUtil : Local network interface found: wlp2s0 192.168.1.104
2016-10-27 11:19:02.142 DEBUG 9390 --- [nio-8085-exec-3] d.f.util.ConnectivityCheckUtil : Your ip is: 192.168.1.104
2016-10-27 11:19:02.144 DEBUG 9390 --- [nio-8085-exec-3] d.f.i.v.b.i.w.s.BrokerWebsocketHandler : Connected ... 2cbhftw3
2016-10-27 11:19:02.144 INFO 9390 --- [nio-8085-exec-3] d.f.i.v.b.i.w.s.BrokerWebsocketHandler : websocketTextmessagesize = 1000000
2016-10-27 11:19:02.147 DEBUG 9390 --- [nio-8085-exec-3] d.f.i.v.b.i.w.s.BrokerWebsocketHandler : Session 2cbhftw3 closed because of CloseStatus[code=1011, reason=null]
2016-10-27 11:19:02.149 ERROR 9390 --- [nio-8085-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri= http://192.168.1.104:8085/websocket/data/421/2cbhftw3/xhr_streaming ; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to open session; nested exception is org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe] with root cause
java.io.IOException: Broken pipe
:
服务器将抛出此错误。我已经在Netgear和TP-Link的多个路由器上试过了。
我已经尝试在ubuntu下手动设置网络接口设置,但这没有帮助。
任何想法可能会造成这种情况?
BR 丹尼尔
我好像你必须设置一个静态的IP,否则系统会尝试根据线鲨鱼,它没有找到,只是没有连接到达成DNS发现服务预期的IP。
只是固定的同样的问题,添加一行到服务器的hosts文件,somethink像:
appsrv 192.168.1.15