This is an archived forum post. The information may be outdated. Contact us if you have any questions.

java.net.NoRouteToHostException

EmmKay wrote on 2010-06-09:
Hi,

I am using the convertURI method to create a PDF and I get the below error.
Is this because I am behind a firewall? If yes, how can I test this?

Thanks

Exception in thread "main" com.pdfcrowd.PdfcrowdError: java.net.NoRouteToHostException: No route to host: connect
at com.pdfcrowd.Client.callAPI(Client.java:162)
at com.pdfcrowd.Client.convertURI(Client.java:242)
at com.test.Test.withPDFCrowd(Test.java:46)
at com.test.Test.main(Test.java:40)
Caused by: java.net.NoRouteToHostException: No route to host: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at com.pdfcrowd.Client.callAPI(Client.java:130)
... 3 more
support wrote on 2010-06-09:
Does your firewall allow outgoing TCP connections on port 80 (the standard http port)? If not, then sadly you can't use the API from behind your firewall.

Basically, if you can access our website in your browser then you should be able to call the API on the same box. Otherwise there is some other problem -- in such case please give us more information about your environment so we can help you.
EmmKay wrote on 2010-06-10:
Hello,

Thank you for your quick response.

I am able to access your website thru my browser and generate a PDF as well !! Which is the fact that puzzles me the most.
Please let me know what kind of information about our env. will help you debug this issue.

Thanks
support wrote on 2010-06-10:
Please open the attached html file in your browser. It is a form that calls the API. Just fill in your username, api key, and some web page and submit it.

Does it work?
EmmKay wrote on 2010-06-28:
Hi,

Sorry for not getting back sooner. Got back to work after 2 weeks.
I followed your instructions and was able to download the PDF.

Thanks
support wrote on 2010-06-28:
Fine, now we know that you can call the API at least from your browser.

Let's find out whether java applications running on your box are allowed to make outgoing connections. Please compile and run this code:

// file conntest.java
import java.net.*;
import java.io.*;

public class conntest {
    public static void main(String[] args) throws IOException
    {
        URL url = new URL("http://pdfcrowd.com");
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        System.out.println(conn.getResponseCode());
    }
}


It should output '200'. If it fails, add the following line before System.out.println(...);

conn.setRequestProperty( "User-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19 (.NET CLR 3.5.30729)");


If it still fails try to replace pdfcrowd.com with e.g google.com.

What is the result?