WebSocket连接正常使用公共IP地址,但带有主机域名失败
总而言之,我正在尝试连接到我在计算机上运行的Demo Node.js websocket服务器。使用我的公共IP地址有效,但来自我的公共主机名(来自NOIP.com),例如。 示例ddns.net
,它失败了。
详细信息:
- 我有一个Node.js WebSocket服务器在我的本地计算机上运行,请访问端口8010。
- 为了确保我的路由器的端口8010打开和转发,我能够通过
ws:// public-成功连接到它ip-address:8010
, - 但是当我尝试使用
ws://example.ddns.net:8010
时,它会失败。 - 我使用 https://www.noip.com/ 将我的public-ip-ip-address映射到hostname ,例如。示例.ddns.net => my-public-ip-address。
- 我可以通过http://成功连接到我的公共主机名,只是不是ws://。
示例:(使用假DNS和IP)
> var ws = new WebSocket('ws://example.ddns.net:8010')
> 'WebSocket connection to 'ws://example.ddns.net:8010/' failed:
(anonymous) @ VM18:1'
> var ws = new WebSocket('ws://public-ip-address:8010')
> (connected)
要注意:
- 我检查了我的公共IP地址是否正确地通过NOIP.com映射到主机名(要获取公共IP,我使用
https:// api。 ipify.org/
) - 我正在使用不安全的Webockets删除任何潜在的SSL原因,
- 我也尝试了安全的WSS插座,如果使用我的主机名URL
我的问题是我如何使用我的问题成功地建立一个Websocket URL中的主机名,如果使用我的公共IP地址,为什么它可以工作?也许端口号通过noip.com时被弄糊?
任何想法都非常感谢,并且非常感谢 以撒
In summary I'm trying to connect to a demo node.js websocket server which I have running on my machine. Using my public ip address works, but from my public hostname (provided from noip.com) eg. example.ddns.net
, it fails.
Details:
- I have a node.js websocket server running on my local machine listening to port 8010.
- To ensure my router has port 8010 open and forwarding correctly, I am able to connect to it successfully via
ws://public-ip-address:8010
- But when I try to connect with
ws://example.ddns.net:8010
it fails. - I use https://www.noip.com/ to map my public-ip-address to a hostname, eg. example.ddns.net => my-public-ip-address.
- I can successfully connect to my public hostname with http://, just not ws://.
Example: (using fake dns and ip)
> var ws = new WebSocket('ws://example.ddns.net:8010')
> 'WebSocket connection to 'ws://example.ddns.net:8010/' failed:
(anonymous) @ VM18:1'
> var ws = new WebSocket('ws://public-ip-address:8010')
> (connected)
To note:
- I've checked that my public-ip-address is correct in the mapping to hostname via noip.com (to get public ip I use
https://api.ipify.org/
) - I'm using insecure websockets to remove any potential ssl causes
- I have also tried secure wss sockets and get the same fail if using my hostname url
My question is how can I successfully establish a websocket using my hostname in the url, and why does it work if using my public IP address? Perhaps the port number is mangled when going through noip.com?
Any thoughts really appreciated and many thanks in advance,
Isaac
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论