我是否需要专用服务器才能启动 MQTT 小型消息代理?
我正在尝试为我的 Android 应用程序实现推送通知。
我只是想知道消息代理是否需要专用服务器。
下载了一个用于 Android 推送通知的开放 php 源代码
从https://github.com/tokudu/PhpMQTTClient
我 将这些 php 文件上传到我的网站。然后我从
非常小的消息代理文件夹中启动了broker.exe。当我从互联网上输入我的网站时
,我的网页显示消息
警告:fsockopen()[function.fsockopen]:无法连接到/ web / home / shlee / html / SAM中的192.168.0.19:1883(连接超时) /MQTT/sam_mqtt.php 第 640 行
所以我使用命令 'telnet 192.168.0.19 1883' 来自命令提示符。
窗口提示没有返回任何错误消息。我对套接字和计算机网络的了解几乎为零
,所以我猜我一定错过了
启动消息代理的一些重要内容。我是否需要专用服务器来启动消息代理?
或者..有什么方法可以从我自己的计算机启动消息代理吗?
提前致谢。
I am trying to implement push notification for my android application.
I am just wondering do I need private server for message broker.
I downloaded an open php source for android push notification from
https://github.com/tokudu/PhpMQTTClient
I uploaded those php files to my website. And then I initiated broker.exe from
really small message broker folder. When I typed my website from the
internet, My webpage displayed the message
Warning: fsockopen() [function.fsockopen]: unable to connect to 192.168.0.19:1883 (Connection timed out) in /web/home/shlee/html/SAM/MQTT/sam_mqtt.php on line 640
So I used command 'telnet 192.168.0.19 1883' from command prompt.
window prompt didnt return any error message. I have almost zero knowledge about
socket and computer networking so I am guessing I must missed something important
to launch a message broker. Do I need private server to launch a message broker?
or.. is there any way to launch message broker from my own computer?
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,您不需要服务器来使用 RSMB,它应该可以在任何有二进制文件的计算机上正常工作。
您是否检查过您的 Windows 防火墙是否已正确设置为允许端口 1883 上的外部连接,这听起来很有可能。
您选择的 php 客户端并不被认为维护得很好或可靠,而且可能是最不稳定和不可预测的 MQTT 客户端!我在这方面取得了更多成功: https://github.com/bluerhinos/phpMQTT
有freenode 上的 MQTT IRC 频道如果您正在寻找特定的帮助,它可能会很慢,但如果您停留足够长的时间,通常会有人回答您的问题。
如果您还没有遇到过,Dale Lane 撰写了一些关于在 Android 上使用 MQTT 的非常全面的博客文章:http://dalelane.co.uk/blog/?p=1599
No you don't need a server to use RSMB it should work fine on any computer there is a binary for.
Have you checked that your windows firewall is correctly set to allow external connections on port 1883, that sounds most likely.
The php client you've chosen is not known as being very well maintained or reliable and maybe just about the most unstable and unpredictable MQTT client around! I've had more success with this one: https://github.com/bluerhinos/phpMQTT
There is an MQTT IRC channel on freenode if you're looking for specific help, it can be slow but if you hang around for long enough someone will usually answer your questions.
If you haven't already come across it Dale Lane has written some very comprehensive blog posts on using MQTT on android: http://dalelane.co.uk/blog/?p=1599
除了 Oliver 所说的之外,192.168.. 属于私有 IP 地址范围。如果运行 Web 服务器的计算机不在该地址范围内,则它将无法连接到运行代理的计算机。
在这种情况下,是的,您需要一台私人服务器或至少一台具有公共可寻址 IP 的计算机。
In addition to what Oliver has said, 192.168.. is in the private range of IP addresses. If the computer running the web server is not also in this address range, it won't be able to connect to the computer running the broker.
In this case, yes, you'd need a private server or at least a computer with a publicly addressable IP.
你只需要这个例子。
此示例将为您提供 PHP 服务器代码和 Android 代码。
Tokudu 示例
You need just this example.
This example will gives you the PHP server code and Android code.
Tokudu example