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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

XML file update causes 0k and can't parse


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?

0 Kudos
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

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.

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.