gpt4 book ai didi

sockets - 如何在 Mosquitto 中同时启用 TCP 和 Web 套接字?

转载 作者:可可西里 更新时间:2023-11-01 02:32:24 27 4
gpt4 key购买 nike

我已经使用 Paho 库通过 MQTT 实现消息传递。在我的 mosquitto.conf 文件中,我有以下内容:

listener 1883
protocol websockets

此配置适用于 Web 应用程序。当我尝试使用 Android 和 iOS 与 TCP 进行连接时,出现错误“连接超时”。当我禁用 protocol websockets 行时,它可以与 Android 和 iOS 一起使用,但随后网页无法连接。

当我尝试测试 MQTT 服务器 test.mosquitto.org 时,一切正常。

请告诉我,我需要它来处理 Android、iOS 和 Web 应用程序,同时支持 WebSockets 和 TCP 连接。

最佳答案

您需要定义两个监听器,一个用于 mqtt over tcp,一个用于 websockets:

# this will listen for mqtt on tcp
listener 1883

# this will expect websockets connections
listener 8080
protocol websockets

关于sockets - 如何在 Mosquitto 中同时启用 TCP 和 Web 套接字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34408624/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com