You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am getting this error panic: context deadline exceeded when trying to create a jetstream stream. I am running my services locally in docker compose including the nats server. NATS version is 2.10.3. Here are two different ways I've tried to create a jet stream:
Approach one
taken directly from nats by example limits example.
natsConn, _:=nats.Connect(natsConnectionString)
// Drain is a safe way to to ensure all buffered messages that were published// are sent and all buffered messages received on a subscription are processed// being closing the connection.// defer natsConn.Drain()// Access `JetStream` which provides methods to create// streams and consumers as well as convenience methods for publishing// to streams and consuming messages from the streams.js, _:=jetstream.New(natsConn)
// We will declare the initial stream configuration by specifying// the name and subjects. Stream names are commonly uppercased to// visually differentiate them from subjects, but this is not required.// A stream can bind one or more subjects which almost always include// wildcards. In addition, no two streams can have overlapping subjects// otherwise the primary messages would be persisted twice. There// are option to replicate messages in various ways, but that will// be explained in later examples.cfg:= jetstream.StreamConfig{
Name: "EVENTS2",
Subjects: []string{"thing.>"},
}
// JetStream provides both file and in-memory storage options. For// durability of the stream data, file storage must be chosen to// survive crashes and restarts. This is the default for the stream,// but we can still set it explicitly.cfg.Storage=jetstream.FileStorage// JetStream API uses context for timeouts and cancellation.ctx, cancel:=context.WithTimeout(context.Background(), 10*time.Second)
defercancel()
// Finally, let's add/create the stream with the default (no) limits.stream, err:=js.CreateStream(ctx, cfg)
iferr!=nil {
panic(err.Error())
}
fmt.Println("created the stream")
jsinfo, err:=stream.Info(nats.Context(ctx))
ifjsinfo==nil {
panic("jetstream info is nil")
}
iferr!=nil {
panic(err.Error())
}
fmt.Println(jsinfo)
// fmt.Println(stream.Info())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Observed behavior
Hi, I am getting this error
panic: context deadline exceeded
when trying to create a jetstream stream. I am running my services locally in docker compose including the nats server. NATS version is 2.10.3. Here are two different ways I've tried to create a jet stream:Approach one
taken directly from nats by example limits example.
Approach 2
NATS config
Questions
ctx
.Thanks
Beta Was this translation helpful? Give feedback.
All reactions