unispeech / unimrcp

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

Is the mrcp message lost ? How the mrcp message tranfer ? #297

Closed lizhenghn123 closed 2 years ago

lizhenghn123 commented 2 years ago

Hi @achaloyan ,

I have a problem: sometimes the mrcp message(ag: speak) may be lost. I trace the logs, and find it can't be callback. see this:

    2021-07-16 17:54:44:408797 src/mrcp_server_connection.c:811 182327040 [INFO]   Receive MRCPv2 Data 10.233.135.12:1544 <-> 10.233.129.106:38981 [483 bytes]
    MRCP/2.0 483 SPEAK 1839510
    Channel-Identifier: f658b120e61a11eb@speechsynth
    Kill-On-Barge-In: false
    Voice-Name: aixia
    Speech-Language: zh-cn
    Content-Type: text/plain
    Content-Length: 288

    中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强
    2021-07-16 17:54:44:409053 message/src/mrcp_start_line.c:256 182327040 [INFO]   mrcp_v2_start_line_parse request_id 1839510
    2021-07-16 17:54:44:409267 src/mrcp_server_connection.c:831 182327040 [INFO]   pool create request(mrcp_server_connection): bee2c68, f658b120e61a11eb, SPEAK, bee2ce8, 1, 0
    2021-07-16 17:54:44:409413 src/mrcp_server_connection.c:748 182327040 [WARN]   Success mrcp_connection_message_receive: f658b120e61a11eb, SPEAK

Please igonre the line-number, i add some logs in these files. The SPEAK message is received, and parsed, but did't transfer to the synth-stata-machine. It seems lose.

These below logs is success(we can see the mrcp_synth_state_machine.c and "Process SPEAK Request" tags):

    2021-07-16 17:54:44:482574 src/mrcp_server_connection.c:811 182327040 [INFO]   Receive MRCPv2 Data 10.233.135.12:1544 <-> 10.233.129.106:38981 [483 bytes]
    MRCP/2.0 483 SPEAK 1905049
    Channel-Identifier: f686846ae61a11eb@speechsynth
    Kill-On-Barge-In: false
    Voice-Name: aixia
    Speech-Language: zh-cn
    Content-Type: text/plain
    Content-Length: 288

    中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强中国人当自强
    2021-07-16 17:54:44:482802 message/src/mrcp_start_line.c:256 182327040 [INFO]   mrcp_v2_start_line_parse request_id 1905049
    2021-07-16 17:54:44:482987 src/mrcp_server_connection.c:831 182327040 [INFO]   pool create request(mrcp_server_connection): bdbc128, f686846ae61a11eb, SPEAK, bdbc1a8, 1, 0
    2021-07-16 17:54:44:483224 src/mrcp_server_connection.c:748 182327040 [WARN]   Success mrcp_connection_message_receive: f686846ae61a11eb, SPEAK
    2021-07-16 17:54:44:483377 src/mrcp_synth_state_machine.c:548 129877760 [INFO]   synth_state_update message_type: f686846ae61a11eb, SPEAK, bdbc1a8, 1
    2021-07-16 17:54:44:483471 src/mrcp_synth_state_machine.c:485 129877760 [INFO]   Process SPEAK Request <f686846ae61a11eb@speechsynth> [1905049]
    2021-07-16 17:54:44:483835 src/demo_synth_engine.c:318 140367616 [INFO]   Set [../data/demo-8kHz.pcm] as Speech Source <f686846ae61a11eb@speechsynth>

How to happened? Answer: When IVR do bench test(eg: 50 concurrency run one hour)。

What environment ? unimrcp: 1.5.0 plugin: demosynth

My Analysis: If i comment the function: apt_task_msg_signal(https://github.com/unispeech/unimrcp/blob/master/libs/apr-toolkit/src/apt_task.c#L261), i can reproduce it.

Can you give some suggests? Thanks a lot .

lizhenghn123 commented 2 years ago

As far as I know, when ivr send one speak message(SPEAK request), the unimrcp will be:

  1. receive、parse、handler、push queue:

    mrcp_server_poller_signal_process       --> mrcp_server_message_handler --> mrcp_connection_message_receive -->  mrcp_server_message_signal --> mrcp_server_connection_task_msg_signal  --> apt_task_msg_signal --> apt_consumer_task_msg_signal
    (receive data, parse it to mrcp message)        (handler mrcp message)          (trigger callback)              (trigger callback)          (package task msg, triger signal callback)  (dispatch task msg)         (push to message queue)
  2. pop queue、callback plugin:

    apt_consumer_task_run      -->  apt_task_msg_process   --> mrcp_server_msg_process  --> mrcp_server_on_channel_message --> mrcp_server_signaling_message_process  --> mrcp_server_signaling_message_dispatch  --> mrcp_state_machine_update  --> synth_state_update  --> synth_request_state_update
    (pop msg from message queue)    (trigger callback)                                  (package signal message)                                                            (dispatch signal message)               (dispatch  synth machine)