Skip to content

[SUGGESTION]More detailed error messages when MQTT client failed to connect #2126

Closed
@LLLLimbo

Description

@LLLLimbo

When I connect to NATS using the MQTT client, I get the following error:

PS D:\Kubernetes\playground\nats\nats-server_> ./nats-server -js -sd D:\Kubernetes\playground\nats\datastore -c mqtt.conf
[7744] 2021/04/19 10:46:56.564893 [INF] Starting nats-server
[7744] 2021/04/19 10:46:56.586893 [INF]   Version:  2.2.2-beta.3
[7744] 2021/04/19 10:46:56.586893 [INF]   Git:      [not set]
[7744] 2021/04/19 10:46:56.586893 [INF]   Name:     NDKS56R6OHWWZRWEX3GWKQTKGBB6TOS66CGZ252MSHTOF7IP4R5253VC
[7744] 2021/04/19 10:46:56.586893 [INF]   Node:     3zV1qX12
[7744] 2021/04/19 10:46:56.587895 [INF]   ID:       NDKS56R6OHWWZRWEX3GWKQTKGBB6TOS66CGZ252MSHTOF7IP4R5253VC
[7744] 2021/04/19 10:46:56.587895 [INF] Using configuration file: mqtt.conf
[7744] 2021/04/19 10:46:56.587895 [INF] Starting JetStream
[7744] 2021/04/19 10:46:56.588893 [INF]     _ ___ _____ ___ _____ ___ ___   _   __  __
[7744] 2021/04/19 10:46:56.588893 [INF]  _ | | __|_   _/ __|_   _| _ \ __| /_\ |  \/  |
[7744] 2021/04/19 10:46:56.588893 [INF] | || | _|  | | \__ \ | | |   / _| / _ \| |\/| |
[7744] 2021/04/19 10:46:56.588893 [INF]  \__/|___| |_| |___/ |_| |_|_\___/_/ \_\_|  |_|
[7744] 2021/04/19 10:46:56.588893 [INF]
[7744] 2021/04/19 10:46:56.589893 [INF]          https://docs.nats.io/jetstream
[7744] 2021/04/19 10:46:56.589893 [INF]
[7744] 2021/04/19 10:46:56.589893 [INF] ---------------- JETSTREAM ----------------
[7744] 2021/04/19 10:46:56.589893 [INF]   Max Memory:      11.77 GB
[7744] 2021/04/19 10:46:56.589893 [INF]   Max Storage:     1.00 TB
[7744] 2021/04/19 10:46:56.589893 [INF]   Store Directory: "D:\\Kubernetes\\playground\\nats\\datastore\\jetstream"
[7744] 2021/04/19 10:46:56.589893 [INF] -------------------------------------------
[7744] 2021/04/19 10:46:56.592893 [INF]   Restored 0 messages for Stream "CONTRACT"
[7744] 2021/04/19 10:46:56.592893 [INF]   Recovering 1 Consumers for Stream - "CONTRACT"
[7744] 2021/04/19 10:46:56.594898 [INF] Listening for MQTT clients on mqtt://127.0.0.1:1883
[7744] 2021/04/19 10:46:56.595894 [INF] Listening for client connections on 0.0.0.0:4222
[7744] 2021/04/19 10:46:56.651893 [INF] Server is ready
[7744] 2021/04/19 10:46:58.530190 [ERR] 127.0.0.1:49488 - mid:9 - not connected
[7744] 2021/04/19 10:55:56.425784 [ERR] 127.0.0.1:49875 - mid:10 - not connected

I cannot find the cause based on the error message.

Here is my MQTT configuration for NATS:

mqtt {
    # Specify a host and port to listen for websocket connections
    #
    listen: "127.0.0.1:1883"
    # It can also be configured with individual parameters,
    # namely host and port.
    #
    host: "127.0.0.1"
    port: 1883

    # TLS configuration.
    #
    #tls {
        #cert_file: "server/configs/certs/cert.new.pem"
        #key_file: "server/configs/certs/key.new.pem"

        # Root CA file
        #
        # ca_file: "/path/to/ca.pem"

        # If true, require and verify client certificates.
        #
        #verify: false

        # TLS handshake timeout in fractional seconds.
        #
        # timeout: 2.0

        # If true, require and verify client certificates and map certificate
        # values for authentication purposes.
        #
        #verify_and_map: false
    #}

    # If no user name is provided when an MQTT client connects, will default
    # this user name in the authentication phase. If specified, this will
    # override, for MQTT clients, any `no_auth_user` value defined in the
    # main configuration file.	
    # Note that this is not compatible with running the server in operator mode.
    #
    # no_auth_user: "my_username_for_apps_not_providing_credentials"

    # See below to know what is the normal way of limiting MQTT clients
    # to specific users.
    # If there are no users specified in the configuration, this simple authorization
    # block allows you to override the values that would be configured in the
    # equivalent block in the main section.
    #
    authorization {
    #     # If this is specified, the client has to provide the same username
    #     # and password to be able to connect.
    #     # username: "limbo"
    #     # password: "limbo"
    #
    #     # If this is specified, the password field in the CONNECT packet has to
    #     # match this token.
    #     # token: "my_token"
    #
    #     # This overrides the main's authorization timeout. For consistency
    #     # with the main's authorization configuration block, this is expressed
    #     # as a number of seconds.
    #     # timeout: 2.0
    }

    # This is the amount of time after which a QoS 1 message sent to
    # a client is redelivered as a DUPLICATE if the server has not
    # received the PUBACK packet on the original Packet Identifier.
    # The value has to be positive.
    # Zero will cause the server to use the default value (30 seconds).
    # Note that changes to this option is applied only to new MQTT subscriptions.
    #
    # Expressed as a time duration, with "s", "m", "h" indicating seconds,
    # minutes and hours respectively. For instance "10s" for 10 seconds,
    # "1m" for 1 minute, etc...
    #
    # ack_wait: "1m"

    # This is the amount of QoS 1 messages the server can send to
    # a subscription without receiving any PUBACK for those messages.
    # The valid range is [0..65535].
    #
    # The total of subscriptions' max_ack_pending on a given session cannot
    # exceed 65535. Attempting to create a subscription that would bring
    # the total above the limit would result in the server returning 0x80
    # in the SUBACK for this subscription.
    # Due to how the NATS Server handles the MQTT "#" wildcard, each
    # subscription ending with "#" will use 2 times the max_ack_pending value.
    # Note that changes to this option is applied only to new subscriptions.
    #
    # max_ack_pending: 100
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions