Timeout options for fetching remote assets
I am in process of changing data centers and I ran into a situation where prince hangs while trying to download images from a remote server. Now, the underlying problem was network related and has been fixed, however, I was surprised to see that prince does not eventually timeout. In my environment, this is a huge problem since I run rails / mongrels which are single threaded. So a few hung mongrels can really affect the application down.
I vaguely recall that prince uses libcurl. Would it be possible to expose the --connect-timeout and --max-time options on the prince command line?
I tried attaching the sample html and strace output to this post, but the forum rejects my upload with "potential attack vector". If needed, I can email you these files instead.
p.s. These tests were performed with Prince 6.0 rev 7 but I did not see anything related in the release notes of the newer versions.
Good idea, we'll investigate timeout options for the next release.
We have now released Prince 8.0 beta, which includes a --http-timeout option.
Is there any option for a general timeout, not just the http? We have a situation we haven't been able to resolve yet and are having to manually kill prince processes daily.
It is trying to request images from a completely different server.
When the images are eliminated it finishes fine.
When NOT in debug mode it finishes fine, images and all.
When in debug mode and locked up, no other web requests from the same user will respond.
By debug mode, do you mean running Prince with the --debug option, or is the web server in debug mode? When Prince fails to complete, what as the last messages it leaves in the log file?
I meant prince in debug mode (--debug). I played with it some more yesterday, and I am convinced that it will render fine with only one image from the remote source (amazon s3). As soon as you add another it does not render. I am guessing adding another image from a different source might be ok.
The last line in the log before killing the pid is the first image loading.
After killing the pid the log reports all images loaded and ends there. I have tried different image formats and sizes to no avail.
We have upgraded the php wrapper with a method to kill the hung process after a certain amount of time. We also closed the php session before handoff to prince in order to make certain the user could navigate to a new page if prince became locked up, so we are in a better situation for now, but a timeout option could be useful in future versions.
Again, it does render fine when not in --debug mode.
Since the only difference when --debug is enabled is that Prince generates a lot more log messages, I would suspect that it is causing some kind of deadlock situation with the wrapper waiting for Prince to finish and Prince waiting for the wrapper to read the messages, thus hanging indefinitely. Which convert method are you calling?
We are using
It appears that there is a bug in Prince where the --debug option is overriding the --silent option, causing lots of log messages to be printed to the standard error stream and causing a deadlock in the PHP wrapper. We will change Prince so that the debug messages only go to the log file specified with setLog(), and this should fix the deadlock. Thanks for letting us know about this issue!
We have fixed the --debug deadlock issue in Prince 8.1 rev 4, available for download now. Thanks again for letting us know.