我们是否需要静态 IP 才能使用 HTML5 Websockets? [英] Do we need a static IP to use HTML5 Websockets?

查看:35
本文介绍了我们是否需要静态 IP 才能使用 HTML5 Websockets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Web 套接字在 PHP 中构建聊天应用程序.我从代码 phpwebsocket 项目此处.该代码在我的本地机器上运行良好,但是当我在我的站点(没有专用 IP)上尝试它时,它在建立 Web 套接字连接时出现问题.我尝试了所有可能的套接字绑定组合(站点地址、外部 ip 地址、本地 ip 地址)但失败了.

I am in the process of building a chat application in PHP using Web Sockets. I started with the code phpwebsocket project and here. The code works fine on my local machine but when i try it on my site (does not have a dedicated IP) it has a problem establishing the web socket connection. I tried it with all possible combinations for socket binding (site addres, external ip addr, local ip addr) but failed.

推荐答案

您必须能够连接到运行 WebSocket 服务器的服务器上的端口.如果您在站点上为 WebSocket 服务器使用 80 或 443 以外的端口,那么您可能需要配置(或询问)站点以接受该端口上的传入连接(因为出于安全原因,他们可能会默认拒绝).如果您无法 telnet 到服务器上的 WebSocket 端口,则可能是这种情况(或者 phpwebsocket 实际上没有正确配置为在该端口上列出).

You must be able to connect to the port on the server where the WebSocket server is running. If you are using a port other than 80 or 443 on your site for the WebSocket server, then you probably need to configure (or ask) the site to accept incoming connections on that port (because they may deny it by default for security reasons). It you are unable to telnet to the WebSocket port on the server, then this is likely the case (or phpwebsocket is not in fact correctly configured to list on that port).

这篇关于我们是否需要静态 IP 才能使用 HTML5 Websockets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆