-
Notifications
You must be signed in to change notification settings - Fork 86
Description
When native.Connect fails to establish a WebSocket connection with Asterisk it logs the error repeatedly in an infinite loop.
There should be a way for the native.Connect function to return an error immediately upon encountering a WebSocket connection issue
cl, err := native.Connect(&native.Options{
Application: app,
Logger: log.With("app", app),
Username: ARI_USERNAME,
Password: ARI_PASSWORD,
URL: "http://" + VOIP_ADDRESS + "/ari",
WebsocketURL: "ws://" + VOIP_ADDRESS + "/ari/events",
})
if err != nil {
log.Error("Failed to build native ARI client", "error", err)
cl.Close()
return false
}
cl.Close()
return true
Steps to Reproduce
1- Configure an incorrect WebSocket URL or invalid credentials.
2- Run the code snippet above.
3- Observe that the error details are not logged adequately.
Expected Behavior
run log.Error("Failed to build native ARI client", "error", err) and return false
Actual Behavior
level=ERROR msg="failed to connect to Asterisk" app=check-qvs44v5 error="websocket.Dial ws://1.2.3.4:8088/ari/events?app=check-qvs44v5: dial tcp 1.2.3.4:8088: connect: connection timed out"
level=ERROR msg="failed to connect to Asterisk" app=check-qvs44v5 error="websocket.Dial ws://1.2.3.4:8088/ari/events?app=check-qvs44v5: dial tcp 1.2.3.4:8088: connect: connection timed out"
level=ERROR msg="failed to connect to Asterisk" app=check-qvs44v5 error="websocket.Dial ws://1.2.3.4:8088/ari/events?app=check-qvs44v5: dial tcp 1.2.3.4:8088: connect: connection timed out"
...