[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #59049] MQTT in FreeRTOS tasks give error on TCP-write

From: Andre
Subject: [lwip-devel] [bug #59049] MQTT in FreeRTOS tasks give error on TCP-write/output
Date: Thu, 1 Oct 2020 05:49:23 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0

Follow-up Comment #4, bug #59049 (project lwip):

Hi Dejan,

First I am not an expert, so keep that in mind.

I think the problem can be simular to mine, since crossing thread on LWIP
can/will mangle up the tcp/ip stack. It can take a while but it will.

First the TCP/IP is a REAL Freertos thread, lets call this task0, but DHCP is
running on the LWIP timers (which run in task0). This is also true for HTTPD.
So what I did is running the MQTT thread in a lwip timer, so MQTT runs from
task0. This solved my troubles. 

There are CYCLIC timers in LWIP, but they are not accesibly to 'user-program'.
But you can add them into the source code.
I do prefer my one-shot timer, since it will not touch the LWIP code.


So for example. Something like this.

  // This will start the MQTT System after 15 seconds
 sys_timeout(15000, MQTT_Task, NULL);

// So this is the task that does the workload and it will restart every
void MQTT_Task(void *arg)
    err_t err;
    (void) arg;

    tMS reloadTimer = 1000;

    if (dns_gethostbyname(      dMQTT_SERVER_NAME, &mqttTask.serverIP,
MQTTServerFound, NULL) == ERR_OK)
        switch (mqttTask.status)
            case eMQTT_INIT:
                mqttTask.counterMS = dMS(0);
                err = mqtt_client_connect(mqttTask.client, &mqttTask.serverIP,
dMQTT_PORT, MQTT_ConnectionCB, 0, &ci);
                if(err == ERR_ISCONN)


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]