nats-io / nats.py

Python3 client for NATS

Home Page:https://nats-io.github.io/nats.py/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in URL Normalization from List in client.py class

OnSuorce opened this issue · comments

Observed behavior

Currently, if you try to connect by passing a list of incomplete URLs (e.g., ["nats://nats", "nats://nats-1", "nats://nats-2"] or ["nats", "nats-1", "nats-2"]), the client fails to connect, while connecting using just one of the items from the list is successful.

Expected behavior

Essentially, when a URL is passed as a single string, it gets normalized, but when taken from a list, this does not happen.

Server and client version

NATS server (Docker image): 2.10.14
NATS Python client: 2.7.2

Host environment

Host environment not relevant

Steps to reproduce

Writing incomplete URLs as below will result in a connection refused exception

options = {
            "servers": ["nats", "nats-1", "nats-2"],
            "max_reconnect_attempts": 10,
            "reconnect_time_wait": 2
        }
await self.nc.connect(**options)

The following code snippets will run fine:

"servers": ["nats://nats:4222", "nats://nats-1:4222", "nats://nats-2:4222"],
"servers": "nats-1",