Hello,
I am working on a project that uses Azure as a cloud IoT provider and the NRF9160 as a gateway-like device which is supposed to make simultaneous connections to up to 5 end devices. I am using an older version of the SDK before the Azure library / example was merged in.
This gateway functionality is working well with up to 2 simultaneous TLS / MQTT connections, but if more than 2 connections is attempted, mqtt_connect returns -45 which is "EOPNOTSUPP 45 /* Operation not supported on socket *". I have seen some other posts that claim the -45 error is because of credential problems with TLS but I am confident this isn't the case here.
I have taken a look at the new Azure library and have found a define that is a little suspicious to me and may indicate there is some hard limit of 2 simultaneous connections. This define is TLS_MAX_CONTEXTS and it is set to 2 in the new library.
My question is: Is there a hard limit for the amount of TLS connections that can be made at the same time? From my testing it seems that limit is 2. I have attached a debug trace here which shows the first 2 successful connections and the error on the 3rd connection attempt. Thanks in advance
00> [00:00:26.356,018] <dbg> net_mqtt.mqtt_subscribe: (0x20021fcc): [CID 0x200200fc]:[State 0x06]: << result 0x00000000 00> [00:00:26.673,248] <dbg> net_mqtt.mqtt_input: (0x20021fcc): state:0x00000006 00> [00:00:26.673,278] <dbg> net_mqtt_dec.unpack_uint8: (0x20021fcc): >> cur:0x20025bd0, end:0x20025bd2 00> [00:00:26.673,278] <dbg> net_mqtt_dec.unpack_uint8: (0x20021fcc): << val:90 00> [00:00:26.673,309] <dbg> net_mqtt_dec.packet_length_decode: (0x20021fcc): length:0x00000003 00> [00:00:26.673,339] <dbg> net_mqtt_rx.mqtt_handle_packet: (0x20021fcc): [CID 0x200200fc]: Received MQTT_PKT_TYPE_SUBACK! 00> [00:00:26.673,370] <dbg> net_mqtt_dec.unpack_uint16: (0x20021fcc): >> cur:0x20025bd2, end:0x20025bd5 00> [00:00:26.673,370] <dbg> net_mqtt_dec.unpack_uint16: (0x20021fcc): << val:04d2 00> [00:00:26.673,370] <dbg> net_mqtt_dec.unpack_data: (0x20021fcc): >> cur:0x20025bd4, end:0x20025bd5 00> [00:00:26.673,400] <dbg> net_mqtt_dec.unpack_data: (0x20021fcc): << bin len:00000001 00> Subscribed3! 00> 00> Connecting on Client4[00:00:34.244,201] <dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20021fcc): Created socket 5 00> [00:00:36.293,395] <dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20021fcc): error5 00> mqtt_connect4 -45 00> 00> [00:00:40.487,915] <dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20021fcc): Created socket 5 00> [00:00:42.531,188] <dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20021fcc): error5 00> mqtt_connect4 -45 00> 00> [00:00:47.039,398] <dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20021fcc): Created socket 5 00> [00:00:48.841,461] <dbg> net_mqtt_sock_tls.mqtt_client_tls_connect: (0x20021fcc): error5 00> mqtt_connect4 -45 00>