-
Notifications
You must be signed in to change notification settings - Fork 689
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 "context deadline exceeded" #1603
Comments
Hey @jdupont22, thank you for creating the issue - we will take a look at it shortly. |
@jdupont22 I could not reproduce the problem using your gist, because if you don't connect initially, you'll never even attempt to get the KV right? if (n.conn == nil) || !n.conn.IsConnected() {
fmt.Println("AfterConnect | Skip NATs, not connected")
return
} So there is no way to get to the panic in your gist unless we are actually connected, unless I'm not executing something correctly. However, I get what you are encountering and I have a suggestion. You're doing the right thing re-creating the connection in We recently fixed a bug where After adjustments, this is what your func main() {
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
n := natsBroker{
ctx: &ctx,
}
connEstablishedHandler := func(nc *nats.Conn) {
fmt.Printf("Got connected to %v!\n", nc.ConnectedUrl())
n.afterConnect()
}
nc, err := nats.Connect(nats.DefaultURL, nats.RetryOnFailedConnect(true),
nats.MaxReconnects(-1),
nats.ReconnectHandler(connEstablishedHandler),
nats.ConnectHandler(connEstablishedHandler),
)
if err != nil {
fmt.Println("Nats err ", err)
return
}
n.conn = nc
for {
select {
case <-ctx.Done():
return
default:
time.Sleep(5 * time.Second)
}
}
} Let me know if that helps. |
Do you create the KV with R=1? Those look like the errors you would get when the server with the stream is down. |
Observed behavior
I want to create a KV watcher resilient to no connection or lost connection.
I've configure the Nats connection with reconnect every 2s, retry on failed connect.
Work great if connection is lost after been connected.
But I have a "context deadline exceeded" if I launch the program with Nats server stopped, and after few seconds, started
Expected behavior
Have a KV watcher available when no connection (next connection succeed) or connection lost (next restore)
Server and client version
server => 2.10.11
client => 1.34.0
Host environment
server launch with Docker Compose in my local machine
client launch in my local machine
Steps to reproduce
Launch the following code with Nats server stopped, after few seconds, start the server
Gist
The text was updated successfully, but these errors were encountered: