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: 
liran
Visitor

[SOLVED] Async HTTP requests

Hello

I am trying to make an Asynchronous HTTP request by his code:

http = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
http.SetPort(port)
http.SetUrl("http://mysite.com") ' should return response in up to 30 seconds.

' SSL certicate, a must for HTTPS addresses !
http.SetCertificatesFile("common:/certs/ca-bundle.crt")

rsp = http.AsyncGetToString()
message = wait(0,port)
print message.GetResponseCode()
print message.GetString()
print message.GetFailureReason()

And it fails:
-28

Connection time-out


What is the reason for this ?

Thanks
0 Kudos
7 REPLIES 7
destruk
Binge Watcher

Re: Async HTTP requests

Is your server sending any response to the roku? What happens when you pull it up in your browser?
0 Kudos
liran
Visitor

Re: Async HTTP requests

The response is shown at the browser, after 30 seconds max (on purpose).
This is why I want to handle it asynchronously, and it doesn't work.
0 Kudos
destruk
Binge Watcher

Re: Async HTTP requests

What if you lower the time for the response for testing? Maybe try 1 second, see if that works, then try 5 seconds, 10, 15, 20, until it fails? If it always fails then that will indicate perhaps the response itself is the problem...or could be the certificate.
0 Kudos
TheEndless
Channel Surfer

Re: Async HTTP requests

"liran" wrote:
The response is shown at the browser, after 30 seconds max (on purpose).
This is why I want to handle it asynchronously, and it doesn't work.

I seem to recall, in my testing, there being a built-in 30 second timeout in the roUrlTransfer component, but I'm not 100% sure about that. I'd definitely try what destruk suggests. Your code also appears to be missing the call to InitClientCertificates which could also be causing a problem.
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
RokuMarkn
Visitor

Re: Async HTTP requests

Yes, there's a 30 second connection timeout. I don't think there's a way to change it right now.

--Mark
0 Kudos
liran
Visitor

Re: Async HTTP requests

The time-out is not from the server ! Even when I define at the server to response after 1 second, at the browser the response is gotten after 1 second - My code get stuck at:
message = wait(0,port)
Until about 30~ seconds have passed, the message doesn't get to the port or something.

What's wrong with my code ?

Thanks
0 Kudos
RokuKevin
Visitor

Re: Async HTTP requests

If you send me the link you are trying to connect to, I'll try to diagnose the problem with you. You can PM me the link if you'd like.

--Kevin
0 Kudos