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

NATS Protocol Violation on newline in subject #1809

Open
marshauf opened this issue Feb 27, 2025 · 1 comment
Open

NATS Protocol Violation on newline in subject #1809

marshauf opened this issue Feb 27, 2025 · 1 comment
Labels
defect Suspected defect such as a bug or regression

Comments

@marshauf
Copy link

Observed behavior

Hello,

when publishing a NATS message through nats.go/jetstream.Jetstream.PublishMsg with a newline char at the end of the subject, the method returns with a context deadline exceeded. NGS reports a "Protocol Violation" and seems to disconnect the client.

The nats cli seems to have a similar problem.

Expected behavior

An invalid subject input should not result in a protocol violation.
The SDK client should return an early error about invalid subject.

Server and client version

Server: NGS
Clients:

  • github.com/nats-io/nats.go v1.39.1
  • nats cli 0.1.5

Host environment

No response

Steps to reproduce

nats pub "test
" "test"

Results in

16:02:51 Disconnected due to: EOF, will attempt reconnect
16:02:51 Published 4 bytes to "test\n"
16:02:51 Reconnected [tls://x.x.x.x:4222]
@marshauf marshauf added the defect Suspected defect such as a bug or regression label Feb 27, 2025
@marshauf
Copy link
Author

When subscribing with the NATS cli, the subject is validated:

nats sub "test
"
16:14:59 Subscribing on test

nats: error: nats: invalid subject

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