avs-device-sdk
avs-device-sdk copied to clipboard
Adds rewind function to allow curl seek and retry sending data to server
Issue
- https://github.com/alexa/avs-device-sdk/issues/1526
- About 1 in 10 Alexa requests fail on mobile devices.
- Requests generally fail with one of two errors: curl error code 56 which is "receive error" or curl error code 65 which is "rewind failed"
- I turned on
ACSDK_EMIT_SENSITIVE_LOGS
to output curl error messages and me help investigate what was going on - It looks like the errors (both 56 and 65) are accompanied with this message
"necessary data rewind wasn't possible"
:
CurlEasyHandleWrapper:libcurl:id=AVSEvent-619,text=necessary data rewind wasn't possible
LibcurlHTTP2Request:getResponseCode:responseCode=0
LibcurlHTTP2Connection:streamFinished:streamId=AVSEvent-619,result=Error,CURLcode=56
- It seems that implementing the
CURLOPT_SEEKFUNCTION
and settingCURLOPT_SEEKDATA
will solve this problem - This is a fairly simple change, as
AttachmentReader
already has a seek function which mirrors the implementation ofCURLOPT_SEEKFUNCTION
: Both expect to be able to set the absolute index of the buffer instead of changing the cursor by some delta.
Description of changes:
- Implemented callback functions for
CURLOPT_SEEKFUNCTION
- Add a
rewind
function to the read callbacks - Call
seek
onAttachmentReader
when called from curl
Testing:
Was able to build and run automated tests. This seems to fix the issue. No more 56 or 65 errors.
Hi @jbfitb,
Thank you for the pull request. Our process is to make changes internally and run all test before pushing the change to github in the form of a new release. I have added this to our internal tracking system to be assessed and prioritized.
Thanks, Kenneth