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: 
Trader5050
Newbie

***solved*** ASyncGetToFile fails immediately?

I have a URL (.cgi script) which is returning a .jpeg file. I can copy/paste the URL into my browser and see the image without issue.

But... when I pull that same URL via this code, it returns an INVALID event immediately.


' agent for transferring files
agent = CreateObject("roUrlTransfer")
agent.SetUrl(settings.Url)

print "About to AsyncGetToFile: "; settings.Url; " "; tmpFile

' get it
if (agent.AsyncGetToFile(tmpFile) = false) then
print "AsyncGetToFile never even started!"
end if

event = wait(30000,agent.GetMessagePort())

if type(event) = "roUrlEvent"
print "***";event.GetInt();
print "***";event.GetResponseCode();
print "***";event.GetFailureReason();
print "***";event.GetSourceIdentity()
else if event = invalid
print "AsyncGetToFile timeout"
agent.AsyncCancel()
else
print "AsyncGetToFile unknown event: "; event
endif


I've seen some code using agent.GetPort() instead but the reference at http://sdkdocs.roku.com/display/sdkdoc/roUrlTransfer only lists GetMessagePort()

Any help is appreciated.

****************************************
SOLVED
****************************************


agent = CreateObject("roUrlTransfer")
agentPort = CreateObject("roMessagePort")
agent.SetMessagePort(agentPort)
agent.SetUrl(settings.Url)
0 Kudos
2 REPLIES 2
RokuMarkn
Visitor

Re: ASyncGetToFile fails immediately?

You need to create a message port and call agent.SetMessagePort().

--Mark
0 Kudos
Trader5050
Newbie

Re: ASyncGetToFile fails immediately?

You're good people! I'm getting a different error now but at least I can tell it's trying to make a connection.

Thanks!
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.