我可以使用confluence cli 連接到confluence kafka 集群,但無法使用segmentio 的kafka-go 庫。 我收到以下錯誤。
with SASL: SASL handshake failed: EOF
這是我在 go 中的函數
package consumer import ( "context" "fmt" "log" "os" "time" "github.com/segmentio/kafka-go" "github.com/segmentio/kafka-go/sasl/plain" ) func Consume(ctx context.Context) { // create a new logger that outputs to stdout // and has the `kafka reader` prefix l := log.New(os.Stdout, "kafka reader: ", 0) mechanism := plain.Mechanism{ Username: "my-api-key", Password: "my-api-secret", } dialer := &kafka.Dialer{ Timeout: 10 * time.Second, DualStack: true, SASLMechanism: mechanism, } r := kafka.NewReader(kafka.ReaderConfig{ Brokers: []string{brokerAddress}, // brokerAddress given in confluent cloud cluster settings. Topic: []string{"steps"}[0], // assign the logger to the reader Logger: l, Dialer: dialer, }) for { // the `ReadMessage` method blocks until we receive the next event msg, err := r.ReadMessage(ctx) if err != nil { panic("could not read message " + err.Error()) } // after receiving the message, log its value fmt.Println("received: ", string(msg.Value)) } }
我嘗試產生新金鑰、使用我的帳戶使用者名稱和密碼、減少分區,但沒有任何效果。
看來您的伺服器的TLS
版本不被接受,您可以使用MinVersion
強制go -kafka 接受它:
dialer := &kafka.Dialer{ Timeout: 10 * time.Second, DualStack: true, SASLMechanism: mechanism, TLS: &tls.Config{ MinVersion: tls.VersionTLS12, }, }
以上是無法使用segmentio的kafka-go連接到Confluence Kafka的詳細內容。更多資訊請關注PHP中文網其他相關文章!