nats.py icon indicating copy to clipboard operation
nats.py copied to clipboard

A dot in consumer name causes error "nats: timeout".

Open rstoye opened this issue 1 year ago • 1 comments

Observed behavior

This is pretty much the same as #471, just for consumer / durable names.

import nats
import pytest

async def my_cool_function():
    nats = await nats.connect("localhost")
    jetstream = nats.jetstream()
    await self.jetstream.add_stream(
        name="cool_stream",
        subjects=["cool_service.*"],
    )

    # subjects can have dots in them, queue, durable, consumer names can't
    jetstream.subscribe("cool_service.my_subject", "name.with.a.dot.in.it", my_callback)

    await nc.close()

def my_callback():
    print("I'm a callback")

Running this code will trigger a "nats: timeout" error on the server side with no further information, not even when running the server in debug / trace mode.

Expected behavior

Arguably this should be handled properly on the server side and return a descriptive error message instead of running in a timeout. I might open up a ticket on the nats-server github later.

The official nats terminal cli throws the following

https://github.com/nats-io/natscli/blob/234eda9cb376add9f1fba4ddffe4ee9cbdb4ed33/cli/consumer_command.go#L1483

fisk.Fatalf("durable name can not contain '.', '*', '>'")

I expected nats.py to validate durable names before sending them to the server and throwing a similar exception.

Server and client version

server: 2.10.23 client: 0.1.5 nats.py: 2.9.0

Host environment

No response

Steps to reproduce

No response

rstoye avatar Dec 11 '24 10:12 rstoye

Can confirm this is still unfixed in 2.10, happend to me just now

lynzrand avatar Jul 29 '25 08:07 lynzrand