Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JetStream] Publishing to a subject without stream will fail in nats.errors.TimeoutError #533

Open
antoinetran opened this issue Feb 19, 2024 · 0 comments
Labels
defect Suspected defect such as a bug or regression

Comments

@antoinetran
Copy link

antoinetran commented Feb 19, 2024

Observed behavior

Doing publish of one message "f" to subject "subjecttest", that has no stream attached to it will result in an error:

Traceback (most recent call last):
  File "/nats-testtools/venv/lib/python3.8/site-packages/nats/aio/client.py", line 1027, in _request_new_style
    msg = await asyncio.wait_for(future, timeout)
  File "/usr/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./nats-testtools/write.py", line 25, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "./nats-testtools/write.py", line 19, in main
    await js.publish("subjecttest", sys.argv[1].encode("UTF-8"))
  File "/nats-testtools/venv/lib/python3.8/site-packages/nats/js/client.py", line 125, in publish
    msg = await self._nc.request(
  File "/nats-testtools/venv/lib/python3.8/site-packages/nats/aio/client.py", line 991, in request
    msg = await self._request_new_style(
  File "/nats-testtools/venv/lib/python3.8/site-packages/nats/aio/client.py", line 1040, in _request_new_style
    raise errors.TimeoutError
nats.errors.TimeoutError: nats: timeout

In NATS server logs, in debug/trace enabled mode, we have:

[7] 2024/02/19 11:05:34.785704 [DBG] 127.0.0.1:36420 - cid:45 - Client connection created
[7] 2024/02/19 11:05:34.790002 [TRC] 127.0.0.1:36420 - cid:45 - <<- [CONNECT {"echo": true, "headers": true, "lang": "python3", "no_responders": true, "pedantic": false, "protocol": 1, "verbose": false, "version": "2.7.0"}]
[7] 2024/02/19 11:05:34.791583 [TRC] 127.0.0.1:36420 - cid:45 - <<- [PING]
[7] 2024/02/19 11:05:34.791600 [TRC] 127.0.0.1:36420 - cid:45 - ->> [PONG]
[7] 2024/02/19 11:05:34.795176 [TRC] 127.0.0.1:36420 - cid:45 - <<- [SUB _INBOX.viiD9p2zfFOkt39Pm6xBvR.*  1]
[7] 2024/02/19 11:05:34.795224 [TRC] 127.0.0.1:36420 - cid:45 - <<- [PUB subjecttest _INBOX.viiD9p2zfFOkt39Pm6xBvR.viiD9p2zfFOkt39Pm6xBxsc881 1]
[7] 2024/02/19 11:05:34.796670 [TRC] 127.0.0.1:36420 - cid:45 - <<- MSG_PAYLOAD: ["f"]
[7] 2024/02/19 11:05:34.796713 [TRC] 192.168.64.1:56047 - cid:12 - ->> [MSG subjecttest 1 _INBOX.viiD9p2zfFOkt39Pm6xBvR.viiD9p2zfFOkt39Pm6xBxsc881 1]
[7] 2024/02/19 11:05:35.143704 [DBG] 192.168.64.1:33689 - cid:5 - Client Ping Timer

Expected behavior

In JetStream mode, when a message has been published to subject without registered stream, it should instead fail with the explicit error: NoStreamFound.

Server and client version

nats server 1.1.7
nats python client 2.7.0

Host environment

NATS server helm chart deployed to Kubernetes cluster
Python 3.8

Steps to reproduce

#!/bin/env python3
import asyncio
import nats
import sys

async def main():
    # Connect to NATS!
    nc = await nats.connect("nats://localhost:4222")
    js = nc.jetstream()
#   try:
#     await js.delete_stream(name = "submitworkflow-poc-nats")
#   except nats.js.errors.NotFoundError as err:
#     pass
#   await js.add_stream(name = "submitworkflow-poc-nats", subjects = ["submitworkflow-poc-nats"])

    # Publish a message to queue
    #await js.publish("submitworkflow-poc-nats", sys.argv[1].encode("UTF-8"))
    await js.publish("subjecttest", sys.argv[1].encode("UTF-8"))

    # Close NATS connection
    await nc.close()

if __name__ == '__main__':
    asyncio.run(main())
@antoinetran antoinetran added the defect Suspected defect such as a bug or regression label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

1 participant