Skip to content

The server name and version could not be captured by using tls.ConnectionState #211

Closed Answered by Zerpet
a2htray asked this question in Q&A
Discussion options

You must be logged in to vote

This is working as intended. You are not dialing to an amqps address, therefore, Dial is not starting a TLS transport. Since it is not using TLS, ConnectionState returns a zero-value, as documented in the function documentation. See also tls#ConnectionState for the fields you can find and their meaning.

By setting a RabbitMQ server that serves over AMQP+TLS, and running this code:

// main.go
	conn, err := amqp.DialTLS("amqps://127.0.0.1:5671", &tls.Config{
		InsecureSkipVerify: true,
	})
	if err != nil {
		errLog.Fatalf("error dialing: %s", err)
	}
	defer conn.Close()

	connState := conn.ConnectionState()
	infoLog.Printf("Server name: '%s'", connState.ServerName)
	infoLog.Printf("Version:…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Zerpet
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #209 on July 12, 2023 12:19.