Forum Discussion
I don't see anything that's obviously wrong in your code and I just tried playing an MP3 from tmp:/ and didn't have a problem. I suspect your MP3 isn't being properly saved to tmp:/. AsyncPostFromFileToFile? Is that what you're using that to save the MP3? I can't say I've ever used it, but check the file that gets saved to tmp:/ with something like roFileSystem stat and/or read it into an roByteArray to check its contents.
Thanks a lot for your response. I followed your instructions and it seems the file is being created, but only the first 4 characters of the response is being stored in the file. If I understand correctly,
msg.GetResponseCode()
returns 200 as soon as the response starts coming in, and it does not wait for the API to return the complete response if the process is not instantaneous. What would be the proper way to make it wait until the response return is complete? I tried a few tweaks but each of them generates new complexities.
- renojim2 years agoCommunity Streaming Expert
I don't know what to suggest on the Roku side, but I usually use something like curl to test interfacing to a server. Something like:
curl --data-raw @command.txt -o apiresponse.out http://apiurl.com/api
That should mimic what AsyncPostFromFileToFile does.
I tried it myself both using curl and on my Roku device connecting to my own server and both worked as expected.
I assume you're using msg = wait(0,port) to wait for the response. It shouldn't be returning until the transfer is complete.
- Rookai2 years agoBinge Watcher
Hi renojim
Thanks a lot for your help. It seems the roURLTransfer works on back of curl. I tested my server with both curl and postman, and they both worked fine and waited until the end of the file was detected (0.7 second to 5 seconds). However, when I run it using AsyncPostFromFileToFile or any other variation of AsyncPost, the port returns immediately and does not wait at all until the response is fully received. Is there anything else you can think of?
Perhaps RokuKevin or RokuAustin could kindly chime in?
- renojim2 years agoCommunity Streaming Expert
My only other thought is packet sniffing and Wireshark, but that can be a pain. I don't know what could be causing it to return immediately. I don't see that in my test, but my test is pretty trivial and everything is local.