简体   繁体   English

Java / Tomcat打开TCP连接-资源监视器

[英]Java/Tomcat Open TCP Connections - Resource Monitor

Right now we are running into a problem where we have a bunch of "open TCP connections" on our Windows server's that are running a tomcat webserver. 现在,我们遇到了一个问题,我们的Windows服务器上运行的是tomcat Web服务器,有一堆“开放的TCP连接”。 The Java code is doing a SOAP call to a vendor, and we see a lot of open connections in Resource Monitor (pictured below) showing the vendor's IP address. Java代码正在对供应商进行SOAP调用,我们在Resource Monitor中看到很多打开的连接(如下图所示),其中显示了供应商的IP地址。 I've tried a couple different methods of doing the SOAP call thinking the connection wasn't explicitly being closed somewhere behind the scenes. 我尝试了几种不同的进行SOAP调用的方法,以为该连接并未在幕后某个地方明确关闭。 Nothing has worked so far, so I'm thinking that I may be misunderstanding what this page is actually showing. 到目前为止,什么都没做,所以我想我可能会误解此页面实际显示的内容。

Windows资源监视器TCP连接以及带有供应商IP的多个java.exe(未灰显)

What is the lifecycle for a TCP connection as it relates to the Windows Resource Monitor? 与Windows资源监视器相关的TCP连接的生命周期是什么? Is it normal for connections that are no longer being used to stay out there for a while? 对于不再使用一会儿的连接是否正常? If not, how do I remedy the situation? 如果没有,我该如何解决?

It'll be either a connection pool or a resource leak in your code. 这将是连接池或代码中的资源泄漏。

To make sure it's not a resource leak check your code to make sure that whatever object is making the network call closes the connection after it's used otherwise you'll be waiting until the garbage collector runs. 为了确保它不是资源泄漏,请检查您的代码以确保使用该网络调用的任何对象均在使用后关闭该连接,否则您将等到垃圾收集器运行。

However, if the network client supports connection pooling then closing it may only place the open connection back into a pool ready for quick re-use. 但是,如果网络客户端支持连接池,则关闭它只能将打开的连接放回池中,以备快速使用。 You don't say which client API you're using but if it supports pooling then it should provide an API to say how long released connections remain in the pool. 您没有说您正在使用哪个客户端API,但是如果它支持池,那么它应该提供一个API来说明释放的连接在池中保留了多长时间。

There is no Windows Winsock-level pooling or persistence. 没有Windows Winsock级别的池或持久性。 If the underlying socket gets closed then that's it, it gets closed. 如果底层套接字被关闭,就是这样,它就会被关闭。

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

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