Skip to content
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

add better debug information on DialConfig #245

Open
alarbada opened this issue Feb 15, 2024 · 2 comments
Open

add better debug information on DialConfig #245

alarbada opened this issue Feb 15, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@alarbada
Copy link

alarbada commented Feb 15, 2024

Is your feature request related to a problem? Please describe.

In my integration tests I'm getting an "EOF" when calling DialTLS. While this looks like a reading file issue, the error context is very poor.

I'm referring to these lines, they have no useful error wrapping:

amqp091-go/connection.go

Lines 199 to 253 in 4a009c7

func DialConfig(url string, config Config) (*Connection, error) {
var err error
var conn net.Conn
uri, err := ParseURI(url)
if err != nil {
return nil, err
}
if config.SASL == nil {
config.SASL = []Authentication{uri.PlainAuth()}
}
if config.Vhost == "" {
config.Vhost = uri.Vhost
}
addr := net.JoinHostPort(uri.Host, strconv.FormatInt(int64(uri.Port), 10))
dialer := config.Dial
if dialer == nil {
dialer = DefaultDial(defaultConnectionTimeout)
}
conn, err = dialer("tcp", addr)
if err != nil {
return nil, err
}
if uri.Scheme == "amqps" {
if config.TLSClientConfig == nil {
tlsConfig, err := tlsConfigFromURI(uri)
if err != nil {
return nil, fmt.Errorf("create TLS config from URI: %w", err)
}
config.TLSClientConfig = tlsConfig
}
// If ServerName has not been specified in TLSClientConfig,
// set it to the URI host used for this connection.
if config.TLSClientConfig.ServerName == "" {
config.TLSClientConfig.ServerName = uri.Host
}
client := tls.Client(conn, config.TLSClientConfig)
if err := client.Handshake(); err != nil {
conn.Close()
return nil, err
}
conn = client
}
return Open(conn, config)
}

Describe the solution you'd like

Better error context would be very useful.

Describe alternatives you've considered

No response

Additional context

No response

@alarbada alarbada added the enhancement New feature or request label Feb 15, 2024
@lukebakken
Copy link
Contributor

Feel free to submit a PR with tests that implements what you would like to see.

@lukebakken lukebakken self-assigned this Feb 15, 2024
@lukebakken
Copy link
Contributor

@alarbada - At the bare minimum, you should provide a way for us to see the same EOF error that is confusing you. Without that, I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants