Hi Users,

We have a scenario, in which we are uploading recording file on "S3" (AWS) after completion of a call through python script.
We encountered error in uploading recording file on S3 for some calls and for some it worked fine. After debugging the issue we have this scenario:
Currently when the calls hangup after being answered (before we get the below mentioned logs in fs_cli), the script returns us an error (logs attached). But if we get the below mentioned [Debug] logs and call hangup after these, no error occurs and script successfully upload the file to s3.
We have not encountered that issue before.

[Debug Logs]
2021-11-19 02:58:08.748629 [DEBUG] switch_ivr_async.c:1427 Record session sample rate: 8000 -> 8000
2021-11-19 02:58:08.748629 [DEBUG] switch_core_media_bug.c:970 Attaching BUG to sofia/external/+18162394364
2021-11-19 02:58:08.768629 [DEBUG] switch_ivr_async.c:1717 No silence detection configured; assuming start of speech
2021-11-19 02:58:09.588628 [DEBUG] switch_rtp.c:7793 Correct audio ip/port confirmed.
2021-11-19 02:58:09.588628 [DEBUG] switch_core_io.c:448 Setting BUG Codec PCMU:0
2021-11-19 02:59:02.468628 [DEBUG] sofia.c:7406 Channel sofia/internal/3175520010@3.210.46.94:12000 entering state [calling][0]
2021-11-19 02:59:02.928627 [DEBUG] sofia.c:7406 Channel sofia/internal/3175520010@3.210.46.94:12000 entering state [ready][200]
2021-11-19 02:59:02.928627 [DEBUG] sofia.c:7416 Remote SDP:
v=0
o=Z 0 2 IN IP4 44.227.145.86
s=Z
c=IN IP4 44.227.145.86
t=0 0
m=audio 57578 RTP/AVP 0 106 9 8 3 101 98
a=rtpmap:106 opus/48000/2
a=fmtp:106 sprop-maxcapturerate=16000; minptime=20; useinbandfec=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:98 telephone-event/48000
a=fmtp:98 0-16

2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5601 Audio Codec Compare [PCMU:0:8000:20:64000:1]/[PCMU:0:8000:20:64000:1]
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5656 Audio Codec Compare [PCMU:0:8000:20:64000:1] ++++ is saved as a match
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5601 Audio Codec Compare [opus:106:48000:20:0:2]/[PCMU:0:8000:20:64000:1]
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5601 Audio Codec Compare [G722:9:8000:20:64000:1]/[PCMU:0:8000:20:64000:1]
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5601 Audio Codec Compare [PCMA:8:8000:20:64000:1]/[PCMU:0:8000:20:64000:1]
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5601 Audio Codec Compare [GSM:3:8000:20:13200:1]/[PCMU:0:8000:20:64000:1]
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5517 Set telephone-event payload to 101@8000
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5860 Set telephone-event payload to 101@8000
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:5918 sofia/internal/3175520010@3.210.46.94:12000 Set 2833 dtmf send payload to 101 recv payload to 101
2021-11-19 02:59:02.928627 [DEBUG] sofia.c:8427 Processing updated SDP
2021-11-19 02:59:02.928627 [DEBUG] switch_core_media.c:8657 Audio params are unchanged for sofia/internal/3175520010@3.210.46.94:12000.
------------------------------------------------------------------------------------------------------------------------------------------

[Upload Error logs]

2021-11-19 02:47:03.348630 [ERR] mod_python.c:317 Error calling python script
2021-11-19 02:47:03.348630 [ERR] mod_python.c:165 Python Error by calling script "s3_upload": <class 'boto3.exceptions.S3UploadFailedError'>
Message: Failed to upload /tmp/3175520010_12028997788_fa1b6644-9779-42bb-a830-6bf51381484f.wav to storage.rvm.sas2.co/3175520010_12028997788_fa1b6644-9779-42bb-a830-6bf51381484f.wav: An error occurred (BadDigest) when calling the PutObject operation (reached max retries: 4): The Content-MD5 you specified did not match what we received.
Exception: None

Traceback (most recent call last)
        File: "/usr/local/freeswitch/scripts/s3_upload.py", line 22, in fsapi
        File: "/usr/local/lib/python2.7/dist-packages/boto3/s3/inject.py", line 131, in upload_file
        File: "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 287, in upload_file
------------------------------------------------------------------------------------------------------------------------------------

Any help in this regard is highly appreciated.

Regards,
Danish Daud