Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[mqtt - enhancement] setting up sock read() chunk size

Aperta
#959 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Inizia individuando l’implementazione MQTT e il percorso di lettura del socket utilizzato per i messaggi in ingresso. Esamina come i blocchi di messaggi vengono forniti al callback e come vengono gestiti i payload di grandi dimensioni. Il lavoro è completato quando viene concordata e implementata una dimensione di lettura limitata senza compromettere la semantica del callback o la consegna completa del payload MQTT.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Im encountering an issue, while transmitting large data (eg. files, ~50kb) over MQTT. The first transmission works flawlessly, but then the ESP has problems to allocate enough heap for further large transmissions in receiving. Blog posts depicts that the problem could be, that the heap is fragmentet after some allocations.

My solution here was to setting up a max chunk size for the read() command, e.g. 1024 byte (multiple of four, to retain the possibility to decode base64 encoded data).

max_size = 1024
left_size = sz
while left_size > 0:
    r = min(max_size, left_size)
    msg = self.sock.read(r)
    left_size -= r
    self.cb(topic, msg, (r<max_size))

The additional bool argument for the callback indicates the completeness of the transmission.

Peter Hinch already mentioned to me (in general) a better solution: send multiple short messages or use an device with SPIRAM. Im not entirely sure if this would fit in my situation, where i publish files via MQTT to update these in the filesystem. So at least I wanted to share my results here once again.

Inadvertent i've initially opened this issue under the mqtt repo of @peterhinch (whoops, that was probably a case of mental derangement, im sorry for that). Here was the intended place.

Lingua principale
Python
Stelle
2.9k
Fork
1.1k
Merge medio
7g 4h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di micropython/micropython-lib

Tutte le issue di micropython/micropython-lib

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.