简体   繁体   English

Tomcat 7和Axis 2的Java套接字超时异常

[英]Java Socket Timeout Exception with Tomcat 7 and Axis 2

We have a Tomcat 7 and Axis 2 for our Java SOAP web service. 我们的Java SOAP Web服务有一个Tomcat 7和Axis 2。 We also use C3PO connection pooling (also in other web services which works fine). 我们还使用C3PO连接池(也可以在其他正常工作的Web服务中使用)。 The web service works for about two days and after that time period it is not working anymore. Web服务工作大约两天,在那段时间后它不再工作了。 Then our consuming customer receives a Java Socket Read Timeout Exception. 然后,我们的消费客户收到Java Socket Read Timeout Exception。 After restarting the Tomcat servlet everything works fine again. 重新启动Tomcat servlet后,一切正常。 Processing the request has a duration of about 3 seconds. 处理请求的持续时间约为3秒。 The Axis 2 has a default socket timeout of 30 seconds. Axis 2的默认套接字超时为30秒。 Our customer has a wait timeout of 60 seconds. 我们的客户等待超时为60秒。 The strange thing about the problem is that it´s working for amount of time and then the problem occurs. 关于这个问题的奇怪之处在于它在一段时间内工作然后问题就出现了。

I don´t know which kind of code I can show here to find the problem. 我不知道我可以在这里找到哪种代码来找到问题。 What causes the socket timeout here? 什么原因导致套接字超时?

Reason of Socket Timeout: 套接字超时的原因:

Socket timeouts can occur when attempting to connect to a remote server, or during communication, especially long-lived ones. 尝试连接到远程服务器或通信期间,特别是长期服务器时,可能会发生套接字超时。

They can be caused by any connectivity problem on the network, such as: 它们可能是由网络上的任何连接问题引起的,例如:

  1. A network partition preventing the two machines from communicating. 阻止两台计算机通信的网络分区。
  2. The remote machine crashing. 远程机器崩溃了。 This cannot easily be distinguished from a network partitioning. 这不容易与网络分区区分开。
  3. A change in the firewall settings of one of the machines preventing communication. 其中一台机器的防火墙设置发生变化,阻止了通信。
  4. The settings are wrong and the client is trying to talk to the wrong machine, one that is not on the network. 设置错误,客户端正在尝试与错误的计算机通信,该计算机不在网络上。 That could be an error in Hadoop configuration files, or an entry in the DNS tables or the /etc/hosts file. 这可能是Hadoop配置文件中的错误,也可能是DNS表或/ etc / hosts文件中的条目。
  5. If its over a long-haul network (ie out of cluster), it may be a transient failure due to the network playing up. 如果它通过长途网络(即群集外),则可能是由于网络播放而导致的瞬态故障。
  6. If using a client of an object store such as the Amazon S3 and OpenStack clients, socket timeouts may be caused by remote-throttling of client requests: your program is making too many PUT/DELETE requests and is being deliberately blocked by the far end. 如果使用对象存储的客户端(例如Amazon S3和OpenStack客户端),则套接字超时可能是由远程限制客户端请求引起的:您的程序正在发出太多的PUT / DELETE请求,并且被远端故意阻止。 This is most likely to happen when creating many small files, or performing bulk deletes (eg deleting a directory with many child entries). 在创建许多小文件或执行批量删除(例如,删除包含许多子条目的目录)时,最有可能发生这种情况。 It can also arise from a transient failure of the long-haul link. 它也可能来自长途链路的短暂故障。

Comparing this exception to the ConnectionRefused error, the latter indicates there is a server at the far end, but no program running on it can receive inbound connections on the chosen port. 将此异常与ConnectionRefused错误进行比较,后者表示远端有一台服务器,但没有运行的程序可以在所选端口上接收入站连接。 A Socket Timeout usually means that there is something there, but it or the network are not working right 套接字超时通常意味着存在某些内容,但它或网络无法正常工作

Identifying and Fixing Socket Timeouts 识别和修复套接字超时

The root cause of a Socket Timeout is a connectivity failure between the machines, so try the usual process 套接字超时的根本原因是机器之间的连接失败,因此请尝试通常的过程

  1. Check the settings: is this the machine you really wanted to talk to? 检查设置:这是您真正想要与之交谈的机器吗?
  2. From the machine that is raising the exception, can you resolve the hostname. 从引发异常的计算机,您可以解析主机名。
  3. Is that resolved hostname the correct one? 解析后的主机名是否正确?
  4. Can you ping the remote host? 你能ping远程主机吗?
  5. Is the target machine running the relevant Hadoop processes? 目标计算机是否运行相关的Hadoop进程?
  6. Can you telnet to the target host and port? 你能telnet到目标主机和端口吗?
  7. Can you telnet to the target host and port from any other machine? 你能从任何其他机器telnet到目标主机和端口吗?
  8. On the target machine, can you telnet to the port using localhost as the hostname. 在目标计算机上,您可以使用localhost作为主机名telnet到端口。 If this works but external network connections time out, it's usually a firewall issue. 如果这可行但外部网络连接超时,则通常是防火墙问题。
  9. If it is a remote object store: is the address correct? 如果是远程对象存储:地址是否正确? Does it go away when you repeat the operation? 重复操作时它会消失吗? Does it only happen on bulk operations? 它只发生在批量操作上吗? If the latter, it's probably due to throttling at the far end. 如果是后者,那可能是由于远端的节流。

Resource Link: 资源链接:

Socket Timeout Details 套接字超时详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM