Skip to content

Configuring an auth method and connecting to a server not requiring authentication causes crash #100

@n-hass

Description

@n-hass

Observed behavior

Specifying an authentication type in the client configuration and trying to connect to a server that does not provide a nonce in the INFO message (i.e. is not configured for authentication) raises a fatal error.

Expected behavior

When the NatsClient is configured to use an authentication method and you try connecting to a server that does not configure any auth control (and hence does not provide a nonce in the INFO payload), the client builds and sends the CONNECT as if there is no authentication required.

This should succeed and not crash in a consuming application. The Go and Java clients behave like this expectation, so I would expect the same here for consistency.

Server and client version

nats-server: v2.11.7
nats.swift: 0.4.0 / current trunk (527205c)

Host environment

A nats-server configured with the following:

jetstream: enabled
jetstream {
  store_dir: /tmp/nats-playground
  max_mem: 1G
  max_file: 5G
  domain: nats-playground-1
}
websocket {
  port: 8888
  same_origin: false
  no_tls: true
}

Steps to reproduce

  1. Run nats-server with above config
  2. Configure NatsClientBuilder with any of credentialPath or nkey (by path or string)
  3. Observe failure on connect with: error: nats: invalid client configuration: missing nonce

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSuspected defect such as a bug or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions