Comments (5)
Hello @kung-foo, thanks for reporting the issue. I'm looking at this (and #1462) and will update you when I have a fix.
from nats.go.
Unfortunately this issue is not something that can be solved client-side.
When publishing a message to a stream, the client is essentially not aware whether there is an underlying stream or not. It simply publishes a standard NATS request (message with reply subject) on a stream's subject and waits for the response. If there is another non-jetstream subscription listening on this subject (and the stream does not exist), this will end with a timeout. The server is also not aware whether the request is jetstream specific or not, since this is a standard NATS message. To know for sure whether there is a stream with interest on the publish subject, we would have to send a separate JetStream request to get the streams, which is not something we want to do on each publish (or even after the timeout is hit).
My suggestion would be to not use the same subject for both stream and standard NATS subscription. If you want a separate subscription to just do the logging, I would suggest creating a simple ephemeral consumer with AckPolicy
set to AckNone
and possibly DeliverPolicy
set to DeliverNewPolicy
(you can use stream.OrderedConsumer()
for simplicity).
from nats.go.
I kinda figured.
There is the ExpectedStreamHeader
option which implies that you can communicate something about JetStream even though it is "just a NATS message".
I think the docs should indicate the limitations of the error response for this API. My reading of the existence of a "retry" option is that any error during publication will trigger a retry. However, it is only an ErrNoResponders
error where a retry is attempted. And since that error is somewhat unreliable, it makes it hard to reason about what will and will not happen.
from nats.go.
Agreed, docs can be improved. ExpectedStreamHeader
is there, but it's optional and is handled within the context of the stream itself, before sending ACK to the client. It is there to make sure that the subject you publish on belongs to the stream you expect. It will not be treated in a special way by the server if the stream for the given subject does not exist.
from nats.go.
There are 3 ways a JS publish can fail and you must catch and log them all:
- No responders
- Timeout
- Error returned by the server (e.g. some limit is hit).
The first 2 cases are equivalent from the client application's perspective: either wait a few seconds and try again or give up.
Will add something about this in the docs.
from nats.go.
Related Issues (20)
- StreamConfig options are not considered when a stream is created HOT 6
- Implement Consumers Pause HOT 1
- [BUG] If the subject is very long, the connection will be broken
- [micro] Add API to read Reply subject from `micro.Request` HOT 6
- undefined: errors.Join HOT 2
- SubscribeSync should return error on permissions violation HOT 3
- jetstream.Consumer.Consume() does not respect ConsumerConfig HOT 1
- Fetch in the JetStream Simplified Client should behave similar to the old API. HOT 5
- jetstream.CreateOrUpdateKeyValue doesn't handle the Domain property of jetstream.ExternalStream correctly when mirroring HOT 1
- jetStreamContext.PublishMsg memory consumption grow over time if nats server fail or restart HOT 1
- Jetstream "context deadline exceeded" HOT 3
- `KeyValue.Watch()` blocks forever for certain values of the `keys` parameter HOT 5
- Listing an Object Store after deleting all objects inside it hangs HOT 3
- JetStream: the value for max pending async messages can be exceeded
- Cannot unsubscribe after panic, alloc lots of memory when startup HOT 8
- kv is created with OLD discard policy using jetstream pkg while with nats pkg it gets NEW HOT 1
- How to retrieve the status of a consumer. HOT 6
- I often get the error `nats: no heartbeat received`
- I often get the error nats: no heartbeat received HOT 19
- Request Reply for JetStream for autoscaling and scaling to zero (similar to Knative) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nats.go.