java WebSockets 和 HTTP 服务器可以在相同的端口号上运行吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29497725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can WebSockets and HTTP server both run on the SAME port number?
提问by manpreetSingh
I have been using GlassFish server, where, index.html is sending the control to servlet file which is sending the control to another nextStep.html file, which is working on WebSockets. Right now, I am confused, as I am getting an error:
我一直在使用 GlassFish 服务器,其中,index.html 将控件发送到 servlet 文件,servlet 文件将控件发送到另一个用于 WebSockets 的 nextStep.html 文件。现在,我很困惑,因为我收到一个错误:
WebSocket connection to 'LocalHost-link' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
WebSocket 连接到“LocalHost-link”失败:连接建立错误:net::ERR_CONNECTION_REFUSED
I think this problem is related to port numbers. Can we use both WebSockets and HTTP server on the same port, if yes, then How ? If we have to use different ports, then how to perform this task in Java ?
我认为这个问题与端口号有关。我们可以在同一个端口上同时使用 WebSockets 和 HTTP 服务器吗?如果是,那么如何?如果我们必须使用不同的端口,那么如何在 Java 中执行此任务?
回答by unwichtich
To provide this question with an answer: Yes, they can.
为这个问题提供一个答案:是的,他们可以。
See also:
也可以看看: