与Tomcat 7的连接被拒绝 [英] Connection refused with Tomcat 7

查看:149
本文介绍了与Tomcat 7的连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Jelastic上运行的Tomcat实例,并且部署了两个应用程序-用于'/foo'上下文和'/bar'上下文.

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

在处理对"/foo"的请求期间,我们对"/bar"进行了HTTP请求(用于授权),并且这里始终存在异常-ConnectException:ConnectionRefused.

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

如果我通过浏览器或本地PC上运行的代码连接到"/bar",则一切运行正常.另外,如果我从服务器(在处理对"/foo"的请求期间)连接到位于其他位置的主机,那么一切也都可以正常工作.看起来Tomcat以某种方式过滤了来自同一主机的传入连接.有人知道该怎么做吗?

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?

推荐答案

拒绝连接"消息表示某些内容无法在传输级别打开网络连接.这很可能意味着您要与之交谈的服务没有在连接尝试中使用的特定IP和端口号上侦听新连接.

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.

检查:

  1. 被拒绝的请求正在使用正确的IP和端口号.
  2. 您的tomcat服务已正确配置为侦听该IP和端口.

请记住,您的系统可能有多个IP地址,并且您需要侦听每个希望使用的IP地址.另外请记住,本地主机"通常是一个不同的IP地址.

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. 如果存在网络级别或本地防火墙阻止流量的可能性,请进行检查.
  2. 如果由于复杂的虚拟网络而导致奇怪"的可能性,请进行检查.

看起来Tomcat以某种方式过滤了来自同一主机的传入连接.

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

Tomcat不会像这样过滤".但是您很有可能没有配置tomcat来侦听请求.检查"server.xml"文件,查看是否已正确配置.

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-我认为这不是Tomcat7 CSRF过滤器.根据文档,这将返回HTTP响应.实际上,除了首先不侦听连接之外,我看不到接收方Tomcat内部的任何内容如何通过任何方式生成连接被拒绝"状态.

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.

这篇关于与Tomcat 7的连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆