nRF9160 MQTT Connection refused

Hi 

I'm trying to send and receive data with MQTT.

I tried uploading asset trackerV2 bin file and it works fine with nrf cloud.

now I want to use the sample "MQTT_simple" to connect to nrf cloud

but it's giving me this error ( I tried as well changing the sec tag to 42 but still the same problem)

my prj.conf is

 

#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# Modem library
CONFIG_NRF_MODEM_LIB=y

# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
CONFIG_MQTT_CLEAN_SESSION=y

# Application
CONFIG_MQTT_PUB_TOPIC="prod/1b1ed61d-1e9e-494d-8eca-a7d9e5c275b8"
CONFIG_MQTT_SUB_TOPIC="prod/1b1ed61d-1e9e-494d-8eca-a7d9e5c275b8"
CONFIG_MQTT_CLIENT_ID="my-client-id"
CONFIG_MQTT_BROKER_HOSTNAME="a2n7tk1kp18wix-ats.iot.us-east-1.amazonaws.com"
CONFIG_MQTT_BROKER_PORT=8883
CONFIG_MQTT_TLS_SEC_TAG=16842753

# Button support
CONFIG_DK_LIBRARY=y

# Enable logging
CONFIG_LOG=y
CONFIG_MQTT_SIMPLE_LOG_LEVEL_DBG=y

# Memory
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=2048

# NewLib C
CONFIG_NEWLIB_LIBC=y

# Modem key management, for provisioning certificates
CONFIG_MODEM_KEY_MGMT=y

I have certificate already installed:

note : I tried connecting to different broker(without TLS) and it works fine

Parents
  • Hi mourad,

    We have noticed that it can take a few seconds to connect to AWS with TLS once the connection to the cellular network has been established. Error No. 111, "connection refused" is common. Connection times range from 1 to 20 seconds and seem to depend partly on cellular signal strength. We're using HTTPS and an API Gateway, not MQTT, but our solution was to increase the connection timeout. Perhaps that will help you?

    Regards,

    Paul

    # Extending socket connection timeout from default of 3,000 ms
    CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=60000
    

Reply
  • Hi mourad,

    We have noticed that it can take a few seconds to connect to AWS with TLS once the connection to the cellular network has been established. Error No. 111, "connection refused" is common. Connection times range from 1 to 20 seconds and seem to depend partly on cellular signal strength. We're using HTTPS and an API Gateway, not MQTT, but our solution was to increase the connection timeout. Perhaps that will help you?

    Regards,

    Paul

    # Extending socket connection timeout from default of 3,000 ms
    CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=60000
    

Children
Related