[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

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

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.

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.

“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.

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

–Mark

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

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