MQTT With GSM PPP and TLS

I am trying to use The GSM PPP sample with MQTT and TLS, I manage to get the NET_L4_CONNECTED event but I cant connect to the broker. I had tested the same broker with other platfroms and it works fine with TLS. My GSM modem is SIM800A connected over UART wit h NRF52840 and I tried both offloading and MBEDTLS, I get Similar results.

I managed to connect to the same broker in the past using the same setup but over insecure transport. It's RabbitMQ with the MQTT plugin if its somehow relevent.

Here is my conf file

CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_PRINTK=y
CONFIG_GPIO=y

CONFIG_MAIN_THREAD_PRIORITY=7

CONFIG_ZIGBEE_SMARTAIR_CLIENT=n
CONFIG_ZIGBEE_SMARTAIR_SERVER=y
CONFIG_ZIGBEE=y
CONFIG_ZIGBEE_APP_UTILS=y
CONFIG_ZIGBEE_ROLE_COORDINATOR=y
CONFIG_MPSL=y
CONFIG_NET_IF_MAX_IPV4_COUNT=4

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192

# Enable nRF ECB driver
CONFIG_CRYPTO=y
CONFIG_CRYPTO_NRF_ECB=y
CONFIG_CRYPTO_INIT_PRIORITY=90

#Networking
CONFIG_NET_IPV6_MLD=n
CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IP_ADDR_CHECK=n
CONFIG_IEEE802154_NRF5=y
CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE=y
CONFIG_IEEE802154_NRF5_UICR_EUI64_REG=0

# GSM modem support
CONFIG_MODEM=y
CONFIG_MODEM_GSM_PPP=y
CONFIG_MODEM_GSM_APN="APN"
CONFIG_GSM_PPP_AUTOSTART=n
CONFIG_MODEM_GSM_FACTORY_RESET_AT_BOOT=y
# PPP networking support
CONFIG_NET_DRIVERS=y
CONFIG_NET_PPP=y
CONFIG_NET_L2_PPP=y
CONFIG_NET_NATIVE=y
CONFIG_NETWORKING=y
CONFIG_NET_L2_PPP_TIMEOUT=10000


# IPv4 enables PPP IPCP support
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
# Network management events
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=5
CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=n
CONFIG_MODEM_SIM_NUMBERS=y
CONFIG_MODEM_CELL_INFO=y
CONFIG_MODEM_SOCKET=y
CONFIG_NET_SHELL=y
CONFIG_MODEM_SHELL=y
CONFIG_NET_L2_PPP_OPTION_MRU=y
#CONFIG_GSM_MUX_MRU_DEFAULT_LEN=1024
CONFIG_NET_PPP_MTU_MRU=2048
CONFIG_NET_PPP_RX_STACK_SIZE=2048
CONFIG_NET_PPP_RINGBUF_SIZE=512
CONFIG_NET_TCP_WORKQ_STACK_SIZE=2048

# # Networking config
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4
CONFIG_MQTT_KEEPALIVE=30
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=4096 #Not sure why, i see and Error that says this value is 0, so make it not 0
CONFIG_TLS_CREDENTIAL_FILENAMES=y
# Network buffers
CONFIG_NET_PKT_RX_COUNT=32
CONFIG_NET_PKT_TX_COUNT=32
CONFIG_NET_BUF_RX_COUNT=64
CONFIG_NET_BUF_TX_COUNT=64
CONFIG_NET_CONTEXT_NET_PKT_POOL=y

# # Enable MBEDTLS
# CONFIG_MBEDTLS_ENABLE_HEAP=y
# CONFIG_MBEDTLS_HEAP_SIZE=56240
# CONFIG_NRF_SECURITY=y
# CONFIG_MBEDTLS_X509_LIBRARY=y
# CONFIG_MBEDTLS_X509_CRT_PARSE_C=y
# CONFIG_MBEDTLS_MD_C=y
# CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y
# CONFIG_MBEDTLS_RSA_C=y
# CONFIG_MBEDTLS_ECDH_C=y
# CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
# # Enable Logging support
CONFIG_NET_LOG=y
CONFIG_NET_TCP_LOG_LEVEL_ERR=y
CONFIG_NET_SOCKETS_LOG_LEVEL_ERR=y
CONFIG_MQTT_LOG_LEVEL_ERR=y
CONFIG_NET_IF_LOG_LEVEL_ERR=y
CONFIG_MBEDTLS_DEBUG=n
CONFIG_NET_CONFIG_LOG_LEVEL_ERR=y
CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_ERR=y
CONFIG_NET_CONTEXT_LOG_LEVEL_ERR=y
CONFIG_NET_PKT_LOG_LEVEL_ERR=y
CONFIG_NET_L2_PPP_LOG_LEVEL_ERR=y
CONFIG_NET_PPP_LOG_LEVEL_ERR=y
CONFIG_MODEM_LOG_LEVEL_DBG=y

Then The log output is:....GSM STARTUP LOGS .....Then:00> [00:00:35.313,446] <inf> sample_gsm_ppp: ###################################### Network connected ######################################
00> [00:00:35.314,666] <dbg> net_conn: conn_register_debug: (): [0x2000d818/6/1/0x3f] remote "The IP address of my server"/8883
00> [00:00:35.314,727] <dbg> net_conn: conn_register_debug: ():   local 0.0.0.0/47228 cb 0x15bbd ud 0x2000d43c
00> [00:00:35.783,142] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:00:35.783,203] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:00:35.783,386] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:35.783,477] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 47228 family 1
00> [00:00:35.783,508] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:35.789,276] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:35.795,593] <inf> net_mqtt_publisher_sample: mqtt_connect -22
00> [00:00:35.884,948] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:00:35.885,009] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:00:35.885,192] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:35.885,284] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 47228 family 1
00> [00:00:35.885,314] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:35.885,437] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:36.203,491] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:00:36.203,582] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:00:36.203,735] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:36.203,826] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 47228 family 1
00> [00:00:36.203,857] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:36.209,655] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:36.382,629] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:00:36.382,720] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:00:36.382,873] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:36.382,965] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 47228 family 1
00> [00:00:36.382,995] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:36.383,117] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:37.883,178] <dbg> net_conn: net_conn_unregister: (tcp_work): Connection handler 0x2000d818 removed
00> [00:00:43.796,722] <dbg> net_conn: conn_register_debug: (): [0x2000d818/6/1/0x3f] remote "The IP address of my server"/8883
00> [00:00:43.796,783] <dbg> net_conn: conn_register_debug: ():   local 0.0.0.0/44109 cb 0x15bbd ud 0x2000d43c
00> [00:00:44.484,222] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:00:44.484,313] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:00:44.484,466] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:44.484,558] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 44109 family 1
00> [00:00:44.484,588] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:44.490,234] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:44.496,032] <inf> net_mqtt_publisher_sample: mqtt_connect -22
00> [00:00:44.544,830] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:00:44.544,891] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:00:44.545,074] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:44.545,166] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 44109 family 1
00> [00:00:44.545,196] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:44.545,318] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:44.885,070] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:00:44.885,131] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:00:44.885,314] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:44.885,406] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 44109 family 1
00> [00:00:44.885,437] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:44.891,021] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:45.023,651] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:00:45.023,712] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:00:45.023,895] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:45.023,956] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 44109 family 1
00> [00:00:45.024,017] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:45.024,108] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:46.524,169] <dbg> net_conn: net_conn_unregister: (tcp_work): Connection handler 0x2000d818 removed
00> [00:00:52.497,161] <dbg> net_conn: conn_register_debug: (): [0x2000d818/6/1/0x3f] remote "The IP address of my server"/8883
00> [00:00:52.497,222] <dbg> net_conn: conn_register_debug: ():   local 0.0.0.0/33755 cb 0x15bbd ud 0x2000d43c
00> [00:00:53.184,692] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:00:53.184,753] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:00:53.184,906] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:53.184,997] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 33755 family 1
00> [00:00:53.185,058] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:53.190,826] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:53.196,990] <inf> net_mqtt_publisher_sample: mqtt_connect -22
00> [00:00:53.244,934] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:00:53.245,025] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:00:53.245,208] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:53.245,269] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 33755 family 1
00> [00:00:53.245,330] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:53.245,422] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:53.603,912] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:00:53.603,973] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:00:53.604,156] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:53.604,217] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 33755 family 1
00> [00:00:53.604,278] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:53.610,137] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:53.784,271] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:00:53.784,332] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:00:53.784,515] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:00:53.784,606] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 33755 family 1
00> [00:00:53.784,637] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:00:53.784,759] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:00:55.284,790] <dbg> net_conn: net_conn_unregister: (tcp_work): Connection handler 0x2000d818 removed
00> [00:01:01.198,120] <dbg> net_conn: conn_register_debug: (): [0x2000d818/6/1/0x3f] remote "The IP address of my server"/8883
00> [00:01:01.198,181] <dbg> net_conn: conn_register_debug: ():   local 0.0.0.0/49579 cb 0x15bbd ud 0x2000d43c
00> [00:01:01.908,294] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:01:01.908,355] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:01:01.908,538] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:01.908,630] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 49579 family 1
00> [00:01:01.908,660] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:01.914,184] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:01.919,921] <inf> net_mqtt_publisher_sample: mqtt_connect -22
00> [00:01:01.944,854] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:01:01.944,915] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:01:01.945,098] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:01.945,190] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 49579 family 1
00> [00:01:01.945,220] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:01.945,312] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:02.304,260] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:02.304,321] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:02.304,504] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:02.304,595] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 49579 family 1
00> [00:01:02.304,626] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:02.310,119] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:02.484,466] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:02.484,527] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:02.484,710] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:02.484,802] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 49579 family 1
00> [00:01:02.484,832] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:02.484,985] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:03.985,015] <dbg> net_conn: net_conn_unregister: (tcp_work): Connection handler 0x2000d818 removed
00> [00:01:09.921,051] <dbg> net_conn: conn_register_debug: (): [0x2000d818/6/1/0x3f] remote "The IP address of my server"/8883
00> [00:01:09.921,112] <dbg> net_conn: conn_register_debug: ():   local 0.0.0.0/52204 cb 0x15bbd ud 0x2000d43c
00> [00:01:10.626,678] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:01:10.626,739] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:01:10.626,922] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:10.626,983] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 52204 family 1
00> [00:01:10.627,044] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:10.632,629] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:10.638,458] <inf> net_mqtt_publisher_sample: mqtt_connect -22
00> [00:01:10.669,036] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:01:10.669,097] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:01:10.669,281] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:10.669,372] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 52204 family 1
00> [00:01:10.669,403] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:10.669,525] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:11.006,652] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:11.006,713] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:11.006,896] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:11.006,988] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 52204 family 1
00> [00:01:11.007,019] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:11.007,141] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:11.046,539] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:11.046,600] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:11.046,783] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:11.046,844] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 52204 family 1
00> [00:01:11.046,905] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:11.052,490] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:11.184,814] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:11.184,875] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:11.185,058] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:11.185,119] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 52204 family 1
00> [00:01:11.185,180] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:11.185,272] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:12.685,333] <dbg> net_conn: net_conn_unregister: (tcp_work): Connection handler 0x2000d818 removed
00> [00:01:18.639,617] <dbg> net_conn: conn_register_debug: (): [0x2000d818/6/1/0x3f] remote "The IP address of my server"/8883
00> [00:01:18.639,648] <dbg> net_conn: conn_register_debug: ():   local 0.0.0.0/53708 cb 0x15bbd ud 0x2000d43c
00> [00:01:19.346,069] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:01:19.346,160] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:01:19.346,313] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:19.346,405] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 53708 family 1
00> [00:01:19.346,435] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:19.352,050] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:19.357,940] <inf> net_mqtt_publisher_sample: mqtt_connect -22
00> [00:01:19.406,127] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 46
00> [00:01:19.406,188] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 46
00> [00:01:19.406,372] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:19.406,463] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 53708 family 1
00> [00:01:19.406,494] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:19.406,616] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:19.706,207] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:19.706,268] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:19.706,451] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:19.706,542] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 53708 family 1
00> [00:01:19.706,573] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:19.712,188] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:19.987,030] <dbg> net_core: net_recv_data: (ppp_workq): prio 0 iface 0x20000cd8 pkt 0x2002d810 len 42
00> [00:01:19.987,121] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x2002d810 len 42
00> [00:01:19.987,274] <dbg> net_ipv4: net_ipv4_input: (rx_q[0]): IPv4 packet received from "The IP address of my server" to 100.118.237.221
00> [00:01:19.987,365] <dbg> net_conn: net_conn_input: (rx_q[0]): Check TCP listener for pkt 0x2002d810 src port 8883 dst port 53708 family 1
00> [00:01:19.987,396] <dbg> net_conn: net_conn_input: (rx_q[0]): [0x2000d818] match found cb 0x15bbd ud 0x2000d43c rank 0x3f
00> [00:01:19.987,518] <dbg> net_core: processing_data: (rx_q[0]): Dropping pkt 0x2002d810
00> [00:01:21.487,579] <dbg> net_conn: net_conn_unregister: (tcp_work): Connection handler 0x2000d818 removedI am down to give the support in NRF a temp account on my server to verify it works with other  platforms.I include the CA cert like this :

static const unsigned char ca_certificate[] =  "ca_cert.der";

and

static int tls_init(void)
{
    int err;

    err = tls_credential_add(APP_CA_CERT_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,
                             ca_certificate, sizeof(ca_certificate));
    if (err < 0)
    {
        LOG_ERR("Failed to register public certificate: %d", err);
        return err;
    }

    return err;
}

I get Success when I call tls_init

my Client start is :

static void client_init(struct mqtt_client *client)
{
    static struct mqtt_utf8 password;
    static struct mqtt_utf8 username;
    struct mqtt_sec_config *tls_config;
    char device_id_username[50];
    sprintf(device_id_username, "mqttvhost:%s", device_id);
   
    mqtt_client_init(client);

    broker_init();

    /* MQTT client configuration */
    client->broker = &broker;
    client->evt_cb = mqtt_event_handler;

    client->client_id.utf8 = (uint8_t *)device_id_username;
    client->client_id.size = strlen(device_id_username);
    password.utf8 = (uint8_t *)device_ic;
    password.size = strlen(device_ic);

    client->password = &password;

    username.utf8 = (uint8_t *)device_id_username;
    username.size = strlen(device_id_username);

    client->user_name = &username;

    client->protocol_version = MQTT_VERSION_3_1_1;

    /* MQTT buffers configuration */
    client->rx_buf = rx_buffer;
    client->rx_buf_size = sizeof(rx_buffer);
    client->tx_buf = tx_buffer;
    client->tx_buf_size = sizeof(tx_buffer);
    /* MQTT transport configuration */
    client->transport.type = MQTT_TRANSPORT_SECURE;

    tls_config = &client->transport.tls.config;
    // int cipherlist[]={0xc02c,0xcca9,0xc0af,0xc0ad,0xc05d,0xc02b};
    tls_config->peer_verify = TLS_PEER_VERIFY_OPTIONAL;
    tls_config->cipher_list = NULL;
    tls_config->cipher_list = 0;
    tls_config->sec_tag_list = m_sec_tags;
    tls_config->sec_tag_count = ARRAY_SIZE(m_sec_tags);
    tls_config->hostname = TLS_SNI_HOSTNAME;
}
static int try_to_connect(struct mqtt_client *client)
{
    int rc, i = 0;

    while (i++ < APP_CONNECT_TRIES && !mqtt_connected) {

        client_init(client);

        rc = mqtt_connect(client);
        if (rc != 0) {
            LOG_INF("mqtt_connect %d", rc);
            k_sleep(K_MSEC(APP_SLEEP_MSECS));
            continue;
        }

        prepare_fds(client);

        if (wait(APP_CONNECT_TIMEOUT_MS)) {
            mqtt_input(client);
        }

        if (!mqtt_connected) {
            mqtt_abort(client);
        }
    }

    if (mqtt_connected) {
        return 0;
    }

    return -EINVAL;
}

Any support on this is appricated.

  • Dears Any help on this? I am very close to changing the platfrom all together with something else that has working TLS examples. I tried to use the psa-tls Examples from the NCS repo and still get get errors in connections (Namely MBEDTLS 0x7780 Error and 0x7080) Is there something I am missing? you can review my broker TLS settings on www.ssllabs.com/.../analyze.html it looks fine to me. Please offer any input.

  • Hello, 

    I'm afraid I can't speak for the SIM800A, as this is not part of our product portfolio and I'm not aware how this part works. You have a fairly complex application with Zigbee, crypto, and a lot of extra setting compared to the standard gms_modem sample and e.g. mqtt_publiser from the Zepyr samples.

    What version of the nRF Connect SDK are you running? 

    You could ask the Zephyr community on Discord, as they might have more experience with the SIM800A.

    Kind regards,
    Øyvind

  • Could you at least give me an example that works with MBEDTLS and no offloading. The SIM800A doesn't support offloading for anything beyond tls1 so Its not going to work anyway. Is there a possibility of making mqtt and tls work directly on the nrf52840 while using PPP as a transport only? surely there is a way, I saw an example on NCS repo for PSA-TLS is it possible to port that to my app. Also I am trying to get more logs out of the tls handshake but I only get <err> net_sock_tls: TLS handshake error: -7780, How do I make the log level for this DBG? I couldnt't find a way.

  • What version of the nRF Connect SDK are you using?

    Belalshinnawey said:
    I saw an example on NCS repo for PSA-TLS

    I'm not familiar with this sample. It is not used by our developers in regards to TLS. Please look at how TLS is used in e.g. Download_client.

    Belalshinnawey said:
    TLS handshake error: -7780

    This is an error which unfamiliar to me, i.e. it is not found in errno.h.

    Belalshinnawey said:
    Could you at least give me an example that works with MBEDTLS and no offloading.

    Have you looked at the samples for MQTT in the Zephyr repository and the equivalent documentation? I.e. MQTT Publisher sample and MQTT networking API

    You could look at the AWS IoT Core sample found under nRF9160 samples. This is our own cellular device which connects to LTE-M or NB-IoT. 

  • I completely gave up on mbedtls. I ported WolfSSL to Zephyr and used it with POSIX to connect with TLS 1.3 . The difference was really just the more meaningful error messages that helped me tune my application. Anyone reading this on NCS v 2.3.0, just download wolfssl and use it, it's way easier and you get error messages that are helpful. Also the code -7780 is an mbedtls error, its not a an nrf error code, it means SSL - A fatal alert message was received from our peer. For some reason, mbedtls was selecting a cipher then returning an error after the server accepted the cipher, all while saying the server returned a fatal alert, even thought the server logs are saying connection is accepted. I couldn't get it to work so I used a library I'm familiar with.

Related