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

XML file update causes 0k and can't parse

Hi,

I'm running into a problem when I sometimes update the current position or add to instant queue of a movie in my channel and the movie's XML file ends up empty. It seems that some the Roku will not wait for the response that the file has been updated and closed before moving on. I'm updating the current position and instant queue via Java Servlets. I call a function that passes the values to the Java Servlet...

conn = CreateObject("roAssociativeArray")
conn.UrlUpdate = "http://" + solrIP + ":8080/UpdatePosition/UpdatePosition?type=" + videoType + "&directory=" + movieTitleForUrl + "&position=" + startTime.toStr()

http = NewHttp(conn.UrlUpdate)

rsp = http.GetToStringWithRetry()

After the response (rsp) statement, the function ends. Are there any suggestions as to how (code) the channel can wait and detect a response back from the server through the servlet, allowing the XML file update to finish and not empty?

Thanks,
Kevin
0 Kudos
2 REPLIES 2
destruk
Streaming Star

Re: XML file update causes 0k and can't parse

You could check the length of the rsp variable, and then loop it if it's 0 bytes. Or check the return code from the http request (200 is OK), or both.
0 Kudos
RokuMarkn
Visitor

Re: XML file update causes 0k and can't parse

Client-side fixes for this problem are difficult to implement so they are completely bulletproof. What if, for example, the file is not empty but half-way written when the client reads it? The best solution is to fix the server so that it never delivers a partially written file. The normal way to do this, at least for Linux/Unix-like systems, is to write the new XML file to a temporary file, then after it is completely written and closed, atomically rename it to the correct name.

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