Connection refused with Tomcat 7

夙愿已清 提交于 2019-12-23 18:18:15

问题


I have a Tomcat instance running on Jelastic and there are two deployed apps - for '/foo' context and for '/bar' context.

During handling request to '/foo' we do a HTTP request to '/bar' (for authorization) and there is always an exception here - ConnectException: ConnectionRefused.

If I connect to '/bar' through browser or from code running on my local PC everything works perfectly. Also if I connect from server (during handling a request to '/foo') to a host located in the different place everything is also work as expected. It looks like that the Tomcat somehow filter incoming connections from the same host. Does anybody know what to do with that?


回答1:


A "connection refused" message means that something was unable to open a network connection at the transport level. This most likely means that the service you are trying to talk to is not listening for new connections on the specific IP and port number that were used in the connection attempt.

Check:

  1. That the request that is being refused is using the correct IP and port number.
  2. That your tomcat service is properly configured to listen on that IP and port.

Bear in mind that your system may have multiple IP addresses, and you need to listen on each one that you wish to use. Also bear in mind that "local host" is typically a different IP address.

Then if neither of the above is the problem:

  1. If there is a possibility of network level or local firewalling blocking the traffic, check that.
  2. If the possibility of "strangeness" due to complicated virtual networking, check that.

It looks like that the Tomcat somehow filter incoming connections from the same host.

Tomcat doesn't "filter" like that. But it is quite possible that you haven't configured tomcat to listen for the requests. Check the "server.xml" file to see if you have configured that correctly.


FWIW - I don't think this is the Tomcat7 CSRF filter. According to the documentation, that would return a HTTP response. In fact, I can't see how anything inside the receiving Tomcat could generate a "connection refused" state by any means other than not listening for connections in the first place.




回答2:


Connection refused definitely means network issue. One of the potential reason is that your application tries to establish connection using http header "host" value etc. and in general header "host" value does not contain 8080 port inside string -BUT- tomcat at Jelastic is running on port 8080, so you can either try connect to your second application forcibly specifying port 8080 or contact your support and ask them to set iptables rule that would redirect all requests (inside your tomcat container) from 80 to 8080 port.



来源:https://stackoverflow.com/questions/16630067/connection-refused-with-tomcat-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!