UMQTT: Library stops receiving broker responses after a subscribed message arrives
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- networking
Hướng nghiên cứu
Bắt đầu với các tệp simple.py và robust.py của umqtt.simple và umqtt.robust, đặc biệt là wait_msg() và các lần đọc socket được nêu trong báo cáo. Tái hiện trên MicroPython v1.24.1 với Raspberry Pi Pico W sau khi một tin nhắn đã đăng ký được nhận, sau đó xác minh rằng các tin nhắn MQTT tiếp theo và các phản hồi xác nhận ping vẫn tiếp tục được nhận mà không cần kết nối lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
MicroPython v1.24.1
Hardware: Raspberry Pi Pico W
Attempted using umqtt.simple v1.5.0 installed via Thonny package manager, as well as manually installing most recent simple.py and robust.py files from GitHub.
I have an IoT application I'm creating with a Raspberry Pi Pico W, and have been trying to get either the umqtt.simple or .robust tools to work for several days now, but am running into a wall where upon receipt of certain messages, the library just freezes and will no longer receive ANY messages until the client connection is completely torn-down and reconnected. I initially thought that this might be some kind of networking issue or socket issue, but it appears to be a function of inbound messages arriving on a subscribed topic.
I've modified simple.py to add a debug print() inside of wait_msg() (right under the "res = self.sock.read(1)") so I can see the raw byte(s) coming back from the socket read, and try and determine where the problem is coming in. I've also implemented a standard ICMP Ping to be able to test network connectivity at the same time as MQTT connectivity, to rule out network-related issues. It's resulted in useful debug output, but I'm no closer to a solution.
Simplified code example:
import network
import ubinascii
import time
from icmp import ping
from umqtt.simple import MQTTClient
from config import *
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(WIFI_SSID, WIFI_PASSWORD)
time.sleep(5)
def mqtt_callback(topic, msg, retained=False, properties=None):
message = msg.decode()
topic = topic.decode()
print(f"Received message: {message} on topic: {topic}, Retained: {retained}, Properties: {properties}")
client_id = ubinascii.hexlify(machine.unique_id()).decode()
client = MQTTClient(client_id, MQTT_BROKER, MQTT_PORT, MQTT_USER, MQTT_PASSWORD)
client.set_callback(mqtt_callback)
client.connect(clean_session=False)
client.subscribe(MQTT_TOPIC_FAN_CONTROL)
client.subscribe(MQTT_DISCOVERY_REQUEST_TOPIC)
client.subscribe(MQTT_TOPIC_FURNACE_STATE)
ping_counter = 0
while True:
if ping_counter >= 10:
print("Pinging ICMP and MQTT")
ping()
client.ping()
ping_counter = 0
else:
ping_counter += 1
client.check_msg()
time.sleep(1)
So it checks for a new message every second, and every 10 seconds it both ICMP pings the MQTT broker host, and MQTT pings the broker service.
Initial output:
Received byte from MQTT server: b'\x90'
Received byte from MQTT server: b'\x90'
Received byte from MQTT server: b'\x90'
Received byte from MQTT server: b'1'
Received message: ON on topic: testtopic/result, Retained: True, Properties: False
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
...
Pinging ICMP and MQTT
ICMP TX(18) : 08 00 16 f4 12 34 00 01 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
ICMP RX(18) : 00 00 1e f4 12 34 00 01 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
IP Version = v4
IP Header = 20
IP Length = 44
Protocol = 0x01
Source = 192.168.1.237
Destination = 192.168.1.131
ICMP Length = 24
ICMP Type = 00
ICMP Code = 00
Checksum = Passed
Identifier = 1234
Sequence N = 0001
ICMP Data = 0123456789ABCDEF
Received byte from MQTT server: None
Received byte from MQTT server: b'\xd0'
Received byte from MQTT server: None
Received byte from MQTT server: None
So, setup proceeds as expected. I subscribe to 3 topics, and get back 3x "\x90" acknowledgement messages. I've configured the messages I'm sending to the broker to be retained, so it then immediately receives a "1" and hits the callback for a received message. A few seconds go by, and we hit our first Ping. The ICMP ping succeeds, so the network is up. A second later, the MQTT server replies with a "\xd0" ping acknowledgement byte. All good so far!
This will run for some arbitrary length of time just fine. And, as far as I can tell, if no messages are sent to subscribed topics, it will run forever. But eventually, after some arbitrary number of messages received, the library just stops responding, even though the network is verifiably up, as is the MQTT broker:
Pinging MQTT Server.
ICMP TX(18) : 08 00 16 f4 12 34 00 01 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
ICMP RX(18) : 00 00 1e f4 12 34 00 01 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
IP Version = v4
IP Header = 20
IP Length = 44
Protocol = 0x01
Source = 192.168.1.237
Destination = 192.168.1.131
ICMP Length = 24
ICMP Type = 00
ICMP Code = 00
Checksum = Passed
Identifier = 1234
Sequence N = 0001
ICMP Data = 0123456789ABCDEF
Received byte from MQTT server: None
Received byte from MQTT server: b'\xd0'
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None **<==== MESSAGE RECEIVED APPROXIMATELY HERE**
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Pinging MQTT Server.
ICMP TX(18) : 08 00 16 f4 12 34 00 01 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
ICMP RX(18) : 00 00 1e f4 12 34 00 01 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
IP Version = v4
IP Header = 20
IP Length = 44
Protocol = 0x01
Source = 192.168.1.237
Destination = 192.168.1.131
ICMP Length = 24
ICMP Type = 00
ICMP Code = 00
Checksum = Passed
Identifier = 1234
Sequence N = 0001
ICMP Data = 0123456789ABCDEF
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Pinging MQTT Server.
ICMP TX(18) : 08 00 16 f3 12 34 00 02 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
ICMP RX(18) : 00 00 1e f3 12 34 00 02 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
IP Version = v4
IP Header = 20
IP Length = 44
Protocol = 0x01
Source = 192.168.1.237
Destination = 192.168.1.131
ICMP Length = 24
ICMP Type = 00
ICMP Code = 00
Checksum = Passed
Identifier = 1234
Sequence N = 0002
ICMP Data = 0123456789ABCDEF
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
Received byte from MQTT server: None
The above output snip shows the point where a message is received. We have a good ping at the beginning. Approximately 5 seconds later, a message is sent on a subscribed topic. The message never arrives, but more importantly neither does anything else, ever again. Even though pings are still being sent, the acknowledgement from the server is never received. ICMP pings to the MQTT broker continue to succeed. The only way to restore operation is to tear down and reconnect the entire MQTT client.
I'm completely baffled and have been unable to determine the cause. Any assistance would be appreciated.
- Ngôn ngữ chính
- Python
- Star
- 2.9k
- Fork
- 1.1k
- Merge trung bình
- 7 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của micropython/micropython-lib
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
micropython/micropython-lib#1074 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
needs-info
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
micropython/micropython-lib#943 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
"requests" does not handle redirection with relative path correctlyCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
micropython/micropython-lib#931 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
micropython/micropython-lib#795 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
webrepl: Support LAN as well as WLAN boards.Có thể đã có người làm @Romaric-RILLET đã nhận 759 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
micropython/micropython-lib#762 ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của micropython/micropython-lib
Issue tương tự
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Có thể đã có người làm @mayureshsonawane17 đã nhận hôm nay. Đang mởWaiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
第二章思考题 8:Skill 追加到末尾不必每轮重新计算 KVĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
bojieli/ai-agent-book#1169 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:low ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenHands/extensions#738 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
micronaut-projects/micronaut-core#13677 ·
Maintainer thường phản hồi trong vòng 1 ngày