Closed a2htray closed 1 year ago
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: %#x", connState.Version)
// Output
// 2023/07/12 12:58:46 [INFO] Server name: ''
// 2023/07/12 12:58:46 [INFO] Version: 0x304
I get the expected results. Note that server name is still empty, because I dialed to an IP address. The number 0x0304 matches the constant for TLS 1.3
Describe the bug
Thanks for this great project.
When using
amqp091-go v1.8.1
andGo 1.19.3
, I found the server name and version could not be captured. The code is simple as follows.Reproduction steps
conn.ConnectionState
to get ConnectionStateConnectionState.ServerName
andConnectionState.Version
Expected behavior
print right server name and version.
Additional context
No response