Try to write everything that xmlReader reads on disk and check the generated file. I have a hunch its either empty or invalid (incomplete) XML. If I'm right, then you may have a timeout that expires earlier than the one you get in a real browser. Either this, or a connection that requires either a close-close connection or keepalive (I saw that the servers were broken like that).
Also, make sure that you do not have a firewall on the server that is running the client, which can block xmlReader from talking to xmlWriter. Try iptables -L in the server console to check any firewall rules.
Edit: You may also need to call something like xmlReader->close() or end() or any other member that you got there that closes the connection and signals to the client that the transfer is complete.
source share