- changed status to invalid
REST API HTTP requests do not close gracefully
I'm trying to trigger a library rescan via batch script on Windows. When using wget to hit the REST API, the command succeeds, but wget does not close the connection and exit; it just sits there until timing out. I thought this might relate to Serviio sending the HTTP header "Content-Length: unspecified" but wget behaves the same way even with the --ignore-length option. I observed this behavior on my Vista box and then reproduced it on a separate XP box to confirm. I am not an expert but I guess this indicates that Serviio is not closing the HTTP connection automatically?
Steps to reproduce:
{{{ wget.exe -O con --post-data "<action><name>forceLibraryRefresh</name></action>" --header "Content-Type: application/xml" --ignore-length -T 10 http://localhost:23423/rest/action
--2011-11-03 14:11:56-- http://localhost:23423/rest/action
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:23423... connected.
HTTP request sent, awaiting response... 200 OK
Length: ignored [application/xml]
Saving to: `con'
[<=> ] 0 --.-K/s 7
0 <?xml version="1.0" encoding="UTF-8" ?> <result> <errorCode>0</errorCode> <httpCode>200</httpCode> </result> 0
[ <=> ] 123 --.-K/s in 10s
2011-11-03 14:12:06 (12.3 B/s) - Read error at byte 123 (Connection timed out).Retrying. }}}
In case someone else is having this problem, I'll mention my workaround: {{{ wget.exe -O con --post-data "<action><name>forceLibraryRefresh</name></action>" --header "Content-Type: application/xml" --ignore-length -T 2 -t 1 http://localhost:23423/rest/action }}} This forces wget to try only once ("-t 1") and to timeout after two seconds ("-T 2"). With these flags my batch script continues after the wget command instead of stalling, and the library is not subjected to rapid repeated rescan requests.
Comments (1)
-
repo owner - Log in to comment
wget doesn't seem to be the right tool to use, it's used more to downloading content, that's probably why it's waiting for more data
I tried it with curl.exe like this and it works:
curl -X POST "http://localhost:23423/rest/action" -H "Content-Type: text/xml" -d "<action><name>forceLibraryRefresh</name></action>"