You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "zhangbiao2009 (via GitHub)" <gi...@apache.org> on 2024/09/25 17:45:21 UTC
[I] Got " Failed to create consumer at reconnect" when stop pulsar broker first and restart it later [pulsar-client-go]
zhangbiao2009 opened a new issue, #1290:
URL: https://github.com/apache/pulsar-client-go/issues/1290
#### Expected behavior
Expect no error happens.
#### Actual behavior
<img width="1631" alt="image" src="https://github.com/user-attachments/assets/0fc0f71e-c433-4cc7-81af-99d5e8ed9928">
#### Steps to reproduce
1. run the go example program
2. stop pulsar broker
3. observe the output of go example, start pulsar broker **after** you see this error message: `error="dial tcp [::1]:6650: connect: connection refused" remote_addr="pulsar://localhost:6650"`
4. you can see the `Failed to create consumer at reconnect` now.
program example to reproduce:
```
package main
import (
"context"
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"github.com/apache/pulsar-client-go/pulsar"
)
func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
// Create a Pulsar client
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://localhost:6650",
})
if err != nil {
log.Fatalf("Could not create Pulsar client: %v", err)
}
defer client.Close()
consumer, err := client.Subscribe(pulsar.ConsumerOptions{
Topic: "my-topic",
SubscriptionName: "my-subscription",
Type: pulsar.KeyShared,
})
if err != nil {
fmt.Printf("Could not create consumer: %v\n", err)
return
}
go func() {
for {
msg, err := consumer.Receive(context.Background())
if err != nil {
log.Printf("Error receiving message: %v", err)
break
}
// Process the message
fmt.Printf("Received message msgId: %v -- content: '%s'\n",
msg.ID(), string(msg.Payload()))
// Acknowledge the message
consumer.Ack(msg)
}
}()
// Keep the main function alive to allow the goroutine to run
select {}
}
```
#### System configuration
Macbook Pro 2021
pulsar go sdk version: 0.13.1
pulsar broker version: latest docker image. I run it with this command:
`docker run -it \
-p 6650:6650 \
-p 8080:8080 \
apachepulsar/pulsar:latest \
bin/pulsar standalone`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org