I'm using the MQTT on my raspberry and on my Ubuntu. I use terminal for start subscriber and publisher and it works so good. But now I want to create a website (using laravel) with this features. I googled it, but I don't find anything interesting. Is it possible to do and how?
1条回答 默认 最新
- doumu1951 2016-09-30 12:45关注
Unlike with HTTP, MQTT is typically used by opening a long-running connection between an application process and a MQTT server.
While it is perfectly possible to open a connection, publish a single message and then close the socket again, it doesn't really work for subscribing to a stream of messages.
PHP's typically mode of operation is to start a process, wait for an HTTP connection, handle the request and then start a new process. This doesn't fit well with the typical MQTT mode of having a long-running process.
This had started to change with people using the PHP built-in HTTP server. I am not sure if Laravel provides a mechanism to keep variables/TCP connections in place between handling requests.
Alternatively it is possible to subscribe to a MQTT topic in a long-running CLI PHP script and persisting it locally (for example a database, KV store, memcache, redis) and then serving the data from the datastore.
It depends a lot on what you are trying to achieve.
解决 无用评论 打赏 举报
悬赏问题
- ¥15 使用ESP8266连接阿里云出现问题
- ¥15 被蓝屏搞吐了,有偿求帮解答,Ai回复直接拉黑
- ¥15 BP神经网络控制倒立摆
- ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
- ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
- ¥30 Unity接入微信SDK 无法开启摄像头
- ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
- ¥20 cad图纸,chx-3六轴码垛机器人
- ¥15 移动摄像头专网需要解vlan
- ¥20 access多表提取相同字段数据并合并