percipia / eslgo

A GoLang FreeSWITCH ESL Library
Mozilla Public License 2.0
97 stars 42 forks source link

Response with content type "text/rude-rejection" freezes opts.Dial function #14

Closed Stratoff closed 2 months ago

Stratoff commented 2 years ago

When FreeSwitch returns a "text/rude-rejection" Response the opts.Dial function keeps waiting a message from channel forever in: <-connection.responseChannels[TypeAuthRequest]

I created a temporary fix adding a new response and an anonymous go routine before the line of the mentioned above

go func () {
  <-connection.responseChannels[TypeRude]
  connection.ExitAndClose()
}()

// First auth
<-connection.responseChannels[TypeAuthRequest]

Tell me if you want me to make a pull request or to find another cleaner solution (I'm sure there's a better way)

Regards.

winsock commented 2 years ago

Hi @Stratoff, thanks for this report!

Your first pass solution certainly looks like it could work for this and shouldn't hurt anything/cause issues with the library. However I think some more research may be needed/looking at FS source code to ensure when this can be thrown. Documentation seems sparse for this particular response type, do you have anymore insight into what can produce this type of response?

From initial searching it seems to happen when FS blocks your connection explicitly instead of just a normal authentication failure? If that is the case and we can assume the connection is dead when receiving that response I can rework the disconnect handler to also catch this case. That would give the advantage that we can let the user of the library know the connection is dead and they can choose what do do from there.