如何解决SocketException:权限被拒绝:连接

我最近遇到一个令我头疼的问题,我需要帮助。

系统由两个子系统组成,分别称为A和B,每个子系统运行在独立的Tomcat实例上,并且当前运行在同一台机器上。 通过Spring httpInvoker (即通过HTTP)调用B的服务。 B系统也通过HTTP调用其他系统的服务。

症状:

  1. 系统开始运行,似乎正常工作大约10-15天;

  2. 在发生exception后系统会运行一段时间:

     org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://xxx.xxx.xxx.xxx/remoting/call]; 

    嵌套的exception是

     java. net.SocketException: **Permission denied: connect** 
  3. 当发生exception时,系统继续。 这总是发生,不仅偶尔。 (看起来有些资源耗尽,但CPU率<5%,内存<15%,networking<5%)。

  4. 当A和B之间的系统调用失败时,B系统通过HTTP调用外部服务也失败了,同样的例外。

  5. 重新启动两个Tomcat服务使整个系统正常工作。

所以重复下面的步骤1-5,我没有find根源。

环境:

  • Windows 2008 R2
  • tomcat7.0.42 x86_64
  • ORALCE盘jdk-1.7.0_40

有任何想法吗?

我有RestTemplate相同的问题。 我改变了初始化使用HttpClient,它解决了我的问题。

这是我使用的春季宣言:

 <code> <bean id="httpClient" class="org.apache.http.impl.client.DefaultHttpClient"> <constructor-arg> <bean class="org.apache.http.impl.conn.PoolingClientConnectionManager"/> </constructor-arg> </bean> <bean id="restTemplate" class="org.springframework.web.client.RestTemplate" > <constructor-arg> <bean class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"> <constructor-arg ref="httpClient"/> </bean> </constructor-arg> </bean> </code> 

这完全解决了这个问题(之前,一些HTTP请求(约14500)之后,我有关于“连接”的错误。