Forum Bugs

Couldn't connect to http host when accessing resources

sstanelle
Hi,

I'm calling Prince from an ASP.Net page using the wrapper classes for using Prince from .Net programs.

It is working great from within the SSL-enabled production site. However, in the non SSL-enabled development environment, I receive a message like the following when Prince tries to load the required resources (style sheets, images, etc.).

http://sympreview.netmarcom.com/html/Datasheet/Layout1/styles/dataSheet.css: warning: couldn't connect to host

I saw something that Prince uses libcurl for http:// URLs, but I don't quite understand how that works or how it might be causing my problem.

I also tried simply accessing the resources using relative URLs, but it seems that Prince insists on pre-pending the host name (i.e. http://sympreview.netmarcom.com).

Any thoughts or suggestions would be appreciated.
mikeday
The link you've posted appears to require a username/password for HTTP authentication. Prince can supply these if you call SetHttpUser() and SetHttpPassword() in the .NET wrapper.
sstanelle
Hi Mike,

Thanks for your reply. I neglected to mention that I am setting the HTTP user and password in the .Net wrapper code. I also verified that the username and password are valid.

Do you have any other thoughts or ideas? The strange thing is that the PDF code was working fine on that server a few months ago.

We also have another stage environment running the same code just fine. The only difference is that one is SSL-enabled whereas the one exhibiting the problem is not.

Also, could you tell me what role libcurl plays in this, if any?

Thanks!

Scott
mikeday
libcurl is just the library that we use for HTTP/HTTPS support. I'm wondering if the issue here might actually be unrelated to HTTPS. Can you try running Prince from the command-line on this simple input document:
<html>
<head>
<link rel="stylesheet" type="text/css"
href="http://sympreview.netmarcom.com/html/Datasheet/Layout1/styles/dataSheet.css"/>
</head>
<body>
Hello
</body>
</html>

When I run this it gives me a warning as the style sheet is password protected: "warning: The requested URL returned error: 401". Do you get this warning, and what messages do you get if you pass a valid --http-user and --http-password? (Please ensure that you run this on the machine that is exhibiting the problem, in case it is some kind of connectivity issue specific to that machine).
sstanelle
Hi Mike,

I ran your piece of test html on the actual server calling Prince from the command line. We were able to determine that sympreview.netmarcom.com is accessible from the outside, but not from within the firewall, which of course is where Prince is running. Our IT is working to resolve this.

As an aside, is it possible to reference resources using relative paths? It seems unnecessary to use the fully qualified reference (i.e. https://sympreview.netmarcom.com/html/Datasheet/Layout1/styles/dataSheet.css), since Prince is running on the same machine. Why not simply html/Datasheet/Layout1/styles/dataSheet.css? When I tried this though, it seems that Prince prepends with https://sympreview.netmarcom.com.

Thanks for your help,

Scott
mikeday
Relative URLs are resolved against the base URL of the document being converted. You can override the base URL with the --baseurl option, or setBaseURL() method. Alternatively, you could use absolute file:// URLs.