unispeech / unimrcp

Open source cross-platform implementation of MRCP protocol
http://www.unimrcp.org
Apache License 2.0
380 stars 167 forks source link

Timeouts not propagated to libunimrcp clients #284

Closed schlagert closed 4 years ago

schlagert commented 4 years ago

I'm facing a problem, where we are running against an MRCP server that - from time to time - seems to stop responding to channel allocation requests, its just not sending anything back. I cannot say that for sure, but it seems to me that there is no callback notified when the corresponding SIP T1x64 timer should have expired. Thus the client hangs until I restart the server which then triggers callbacks on the client (most probably due to the TCP connection being closed). The connection is made using MRCPv2 using TCP as transport.

I know that this sounds pretty vague and I would therefore offer to look into this myself. However, I do not have a clue where to start looking code-wise. Any advice would be appreciated.

schlagert commented 4 years ago

I managed to find the problem myself. It is not part of libunimrcp.

For those of you curious: When a timeout occurs on during the INVITE transaction for a new MRCPv2 channel, the on_channel_add callback gets invoked. On failures, I would try to get rid of the channel/session using the following chain:

  1. mrcp_application_channel_remove
  2. on_channel_remove
  3. mrcp_application_session_terminate
  4. on_session_terminate
  5. mrcp_application_session_destroy

However, when a server becomes unresponsive it is likely, that it will also not reply to the channel removal message (not even with a 400 or whatever). Thus, my session never got terminated in that case. The correct thing to do (I guess) is to skip channel removal and immediately terminate the session.