英文:
Internal Connector Error (1002) - The calling thread timed out while waiting for a response to unblock it
问题
我有一个使用Java 1.8编写的应用程序,尝试与一个Node v8.10应用程序进行通信。
两者都运行在同一台(AWS EC2 Ubuntu 18.04)服务器上。
Java应用程序运行在Tomcat 8容器中,使用https协议,在8443端口上。
Node应用程序运行在pm2容器v4.4.1中,也使用https协议,在8888端口上。
Java应用程序调用Node应用程序的一个路由,使用POST方法传递一些请求体参数。
如果我使用Postman发送请求,或者将我的本地开发Java服务器连接到生产Node应用程序,一切都正常。
但是当两者都在生产服务器上运行时,我遇到了这个错误:
内部连接器错误(1002)- 调用线程在等待响应以解除阻塞时超时。
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)
这是我使用的Maven存储库:
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>2.0.14</version>
</dependency>
这是Java端的代码:
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();
}
希望这些信息有助于解决您的问题。
英文:
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();
}
答案1
得分: 0
这个解决方法是在服务器端编辑 /etc/hosts
文件,并将 DNS 添加到本地主机定义中。
这样,DNS 解析将在本地进行,而不经过互联网,也不会再次在 AWS 服务器上循环,从而似乎可以解决这种情况。
sudo nano /etc/hosts
127.0.0.1 localhost www.mysite.xyz
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论