eslgo icon indicating copy to clipboard operation
eslgo copied to clipboard

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

Open Stratoff opened this issue 3 years ago • 1 comments

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.

Stratoff avatar Dec 15 '21 22:12 Stratoff

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.

winsock avatar Dec 15 '21 23:12 winsock