lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwip, mqtt and mbedtls


From: Manu Abraham
Subject: Re: [lwip-users] lwip, mqtt and mbedtls
Date: Fri, 21 Aug 2020 01:49:34 +0530

Hi,

Replying to my own post.

Found that there is a tls_config pointer which needs to be filled in
the struct mqtt_connect_client_info_t

So, I did:

    mqtt_client_info.tls_config =
altcp_tls_create_config_client(test_ca_crt, test_ca_crt_len);

Which gave me this warning:

altcp_tls: TCP_WND is smaller than the RX decryption buffer,
connection RX might stall!

Which states TCP_WND to be bigger than:

#define MBEDTLS_SSL_MAX_CONTENT_LEN         16384   /**< Size of the
input / output buffer */

So I did change in lwipopts.h

#define TCP_WND                 (12*TCP_MSS)    // was 2

But now, I get an error directive at build time:
D:\Work\LWIP\lwip-2.1.2\src\core\init.c(318): error:  #35: #error
directive: "lwip_sanity_check: WARNING: TCP_WND is larger than space
provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers).
If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS
to 1 to disable this error."

  #error "lwip_sanity_check: WARNING: TCP_WND is larger than space
provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers).
If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS
to 1 to disable this error."

So, What should be done ?

Am I going on the right track, or something is wrong somewhere ?

Thanks,

Manu


On Fri, Aug 21, 2020 at 12:03 AM Manu Abraham <abraham.manu@gmail.com> wrote:
>
> Hi,
>
> I have been trying to use mqtt from lwip-2.1.2 alongwith mqtt and mbedtls.
> Trying to connect to a running mosquitto on a PC (192.168.1.34)
>
> I see that mqtt uses alttcp as a wrapper, which connects to mbedtls,
> which uses lwip_tcp
>
> But, looking at
>
> void
> mqtt_example_init(void)
> {
> #if LWIP_TCP
>   mqtt_client = mqtt_client_new();
>
>   mqtt_set_inpub_callback(mqtt_client,
>           mqtt_incoming_publish_cb,
>           mqtt_incoming_data_cb,
>           LWIP_CONST_CAST(void*, &mqtt_client_info));
>
>   mqtt_client_connect(mqtt_client,
>           &mqtt_ip, MQTT_PORT,
>           mqtt_connection_cb, LWIP_CONST_CAST(void*, &mqtt_client_info),
>           &mqtt_client_info);
> #endif /* LWIP_TCP */
> }
>
> from contrib/mqtt_example.c, it gets connected over tcp.
> Trying to connect using tcp, I get the following debug trace
>
>  IPv4 Address     : 192.168.1.33
>  IPv4 Subnet mask : 255.255.255.0
>  IPv4 Gateway     : 192.168.1.1
>
>  Lease period: 86400s, Renew in: 43200s, Rebind in: 75600s
>
>  (1150) mqtt_example_init: Initializing MQTT client
>  (1161) mqtt_example_init: Connecting to MQTT Broker:192.168.1.34:8883
> tcp_bind: bind to port 52032
> mqtt_client_connect: Connecting to host: 192.168.1.34 at port:8883
> tcp_connect to port 8883
> mqtt_tcp_connect_cb: TCP connection established to server
> mqtt_output_send: tcp_sndbuf: 5840 bytes, ringbuf_linear_available:
> 18, get 0, put 18
> mqtt_tcp_err_cb: TCP error callback: error -14, arg: 30044044
> MQTT client "test" connection cb: status 256
> tcp_pcb_purge
> tcp_pcb_purge: data left on ->unacked
> tcp_slowtmr: no active pcbs
>  (109) print_dhcp_state: Test MQTT publish
> Assertion "mqtt_publish: TCP disconnected" failed at line 1110 in
> D:\Work\LWIP\lwip-2.1.2\src\apps\mqtt\mqtt.c
>  (1219) publish_data: Publish err: -11
>
>
>
> So, how should one connect MQTT when using mbedtls ?
>
> Can someone help ?
>
> Thanks,
>
> Manu



reply via email to

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