krh5150
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2013
09:18 PM
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
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
2 REPLIES 2
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2013
03:04 AM
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.

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2013
06:13 AM
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
--Mark