javanode.jsposthttpsrestlet

Internal Connector Error (1002) - The calling thread timed out while waiting for a response to unblock it


I have a Java 1.8 application that tries to communicate with a node v8.10 application. Both are running on the same (AWS EC2 ubuntu 18.04) server. Java appliciation is running in a tomcat 8 container, with https, on 8443 port. Node application is running in a pm2 container v4.4.1, using https too, on 8888 port.

Java application calls a route of the node application, using POST with some request body parameters.

Everything works fine if I post the query using postman, or if I plug my local dev java server on prod node application. But when both are runnning on prod server, I have this error :

Internal Connector Error (1002) - The calling thread timed out while waiting for a response to unblock it.
    at org.restlet.resource.ClientResource.handle(ClientResource.java:870)
    at org.restlet.resource.ClientResource.post(ClientResource.java:1209)
    ...
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

here is the maven repo I use:

<dependency>
   <groupId>org.restlet.jee</groupId>
   <artifactId>org.restlet</artifactId>
   <version>2.0.14</version>
</dependency>

Here is the code on java side:

        Form form = new Form();
        Client client = null;
        ClientResource resource = null;
        Representation response = null;
        form.add("something", "somevalue");

    try {
        client = new Client(new Context(), Protocol.HTTPS);
        resource = new ClientResource(resourceURI);
        resource.setNext(client);
        response = resource.post(form.getWebRepresentation());
    } finally {
        try {
            response.exhaust();
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
        response.release();
        resource.release();
    }


Solution

  • the solution is to edit /etc/hosts file on server side, and add the DNS to the localhost definition. This way, the DNS resolution is done locally, without going thru internet and looping on AWS server again, which seems to block the situation.

    sudo nano /etc/hosts
    127.0.0.1 localhost www.mysite.xyz