Asterisk records empty files

I developed an IVR which should call a number and recording until silence(2sec) and continue my code. I’m using python to send AGI command (based on this doc https://wiki.asterisk.org/wiki/display/AST/AGICommand_record+file) :

RECORD FILE "/var/asterisk_sound/mobile/temp" wav "" 20000 0  s=2

So when I’m calling IVR, I hear IVR playing audio and sending DTMF to me, it can record my speech and DTMF if i send with my phone. After I have a little file temp.wav like 50kB. Log :

09:57:31:-> RECORD FILE "/var/asterisk_sound/mobile/temp" wav "" 20000 0  s=2
09:57:46:<- 200 result=4852 (timeout) endpos=102880
09:57:46:{'code': '200', 'result': '4852', 'value': 'timeout', 'endpos': '102880'}

But when IVR calls me, I still hear IVR DTMF and audio, but while recording nothing happens, I’m talking and sending DTMF for 20sec(until timeout) without error, log :

16:00:38:-> RECORD FILE "/var/asterisk_sound/mobile/temp" wav "" 20000 0  s=2
16:00:58:<- 200 result=0 (timeout) endpos=0
16:00:58:{'code': '200', 'result': '0', 'value': 'timeout', 'endpos': '0'}

I’have a little file in the end I have a little file temp.wav like 0B.

I’m confused, maybe I try to record a speaker but I don’t think so. I summarized the problem below :

enter image description here

FYI : I’m using Asterisk 13.1-cert1 on a x86_64 CentOS 5.6

Edit :
My algo is doing this in both cases :

call a number
on reply :
    play welcome message (3 sec)
    send DTMF 
    wait 10 sec
    play BEEP
    record file until silence
    stream file
    cancel