Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kbenson
Visitor

roUrlTransfer timeout

Am I missing something, or is there no want to set an explicit timeout for roUrlTransfer? I have a request that takes a while to return, and it's timing out at 30 seconds (CURLE_OPERATION_TIMEDOUT). Preferably, I would like the ability to set a longer timeout explicitly, so this request which is taking a while can finish.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
5 REPLIES 5
renojim
Community Streaming Expert

Re: roUrlTransfer timeout

Have you tried SetMinimumTransferRate()? It may not be exactly what you're looking for, but it might do the trick.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
TheEndless
Channel Surfer

Re: roUrlTransfer timeout

What's the code you're using? If you use a method similar to what's in the SDK examples (function that does an async get, but encapsulates the Wait loop), then you should be able to set an arbitrary timeout on the Wait loop.

Function HTTPGet( url As String, timeoutMS = 0 As Integer ) As String
http = CreateObject( "roUrlTransfer" )
port = CreateObject( "roMessagePort" )
http.SetMessagePort( port )
http.SetUrl( url )
If ( http.AsyncGetToString() )
msg = Wait( timeoutMS, http.GetPort() )
If msg = invalid Then
' Timeout
Return "Error: timed out"
Else If Type( msg ) = "roUrlEvent" Then
Return msg.GetString()
End If
End If
End Function
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
kbenson
Visitor

Re: roUrlTransfer timeout

Unfortunately it has nothing to do with the wait timeout. It's an actual CURL timeout error returned from the request. i can be handling other events fine during that interval, but the only event from the roUrlTransfer AsyncGetToString call is an error type -28.

The SetMinimumTransferRate() seemed like it might be a good bet, but actually I get the same 30 second timeout whether I've required 1 byte in 10 seconds or 1 byte in 60 seconds. This seems odd, as I figured others would have used this and noted if it wasn't, so possibly I'm doing it wrong, or maybe that only functions after some data has actually been received.


request = CreateObject("roURLTransfer")
request.setPort(m.port)
request.setURL(DELAYED_RESPONSE_URL)
print "sending request"
request.SetMinimumTransferRate(1,60)
timer.mark()
result = request.aSyncGetToString() ' returns boolean


As stated, the only event passed from this is a CURL timeout error.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
renojim
Community Streaming Expert

Re: roUrlTransfer timeout

I was afraid SetMinimumTransferRate() might behave as you described. I've used it, but in my case the connection returned something immediately and then kept the connection open to periodically send more data. I used SetMinimumTransferRate() to close the connection when there was a long enough pause in the data being returned. If you're controlling both ends can you return something immediately while you're working on the rest of the response?

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
kbenson
Visitor

Re: roUrlTransfer timeout

Actually I don't control the other end. This may be a non-issue though, as some more investigation turns up that they are actually responding immediately, albeit with a 302 redirect to a domain that isn't answering at all (nothing listening on port 80). Given the circumstances, I can't really fault roUrlTransfer, it might be working fine except for when the remote server literally doesn't even accept the connection, I wouldn't know.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.