我们在生产中遇到问题已经有一段时间了......
这是以下内容的跟进:my other question但有更具体的方式,所以我认为将其作为一个新问题发布是合理的(如果不是,我只会将此信息添加到另一个问题)。
这里是:
因此,我们使用使用 cxf 的应用程序使用 (ibm) java 6 weblogic 在 aix 上发生文件描述符泄漏,我们解决了我们自己的 Web 服务以及路由到我们的 ws 的 jsb。
使用 File Leak Detector 时作为 weblogic 启动中的代理,转储 getCurrentOpenFiles() 并以编程方式过滤 Listener.SocketRecord,我们有 2000 多个打开的套接字;
这些是 java 套接字和文件描述符,网络套接字(使用 netstat 查看)按时间正确关闭,但是程序化套接字(以及使用查看的)
lsof -p $pid_of_managed_server 2> /dev/null|grep TCP|wc -l
)保持打开状态(并最终导致打开文件过多的问题))。
这是 jvm 中那些打开的文件描述符之一的栈的头部:
record socket to tst-cjcsr.com/10.239.7.19:443 by thread:[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' on Thu Nov 10 10:25:56 CET 2016
at java.net.PlainSocketImpl.create(PlainSocketImpl.java:188)
at java.net.Socket.createImpl(Socket.java:411)
at java.net.Socket.connect(Socket.java:544)
at weblogic.net.http.HttpsClient.openWrappedSSLSocket(HttpsClient.java:565)
at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:296)
at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:373)
at weblogic.net.http.HttpsClient.New(HttpsClient.java:528)
at weblogic.net.http.HttpsURLConnection.connect(HttpsURLConnection.java:239)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:409)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1038)
at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:266)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1550)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1579)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1520)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1317)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:572)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:481)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:136)
at com.sun.proxy.$Proxy380.requestOurRecord(Unknown Source)
at some.package.application.dossier.DossierBean$1.call(DossierBean.java:225)
我可以想象这是一个应用问题,因为我在网上找不到其他类似缺陷的案例。
有没有人能从这个堆栈中得到更多的意义?
例如:令我感到奇怪的是 HTTPConduit.close() 想要创建一个连接...
还有一点: 非 https 调用的相同技术堆栈不会出现此问题。 (这确实有意义,因为堆栈跟踪提到了 HttpsClient)
CXF版本:2.7.18
cxf 配置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<context:property-placeholder location="file:${config.file.location}cjr-extract-${environment}.properties"/>
<jaxws:client id="OurService"
serviceClass="some.package.ws.extract.generated.OurService"
address="${ws.extract.wsdl.endpoint}">
<jaxws:binding>
<soap:soapBinding version="1.2"/>
</jaxws:binding>
</jaxws:client>
<cxf:bus>
<cxf:outInterceptors>
<bean class="our.package.interceptors.SomeInterceptor"
id="webSecurityInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Timestamp Signature"/>
<entry key="user" value="${org.apache.ws.security.crypto.merlin.keystore.alias}"/>
<entry key="passwordCallbackRef">
<ref bean="passwordCallBack"/>
</entry>
<!--entry key="signaturePropFile" value="properties/our.properties"/-->
<entry key="signaturePropFile" value="file:${location}/our.properties"/>
<entry key="signatureKeyIdentifier" value="DirectReference" />
</map>
</constructor-arg>
</bean>
</cxf:outInterceptors>
<cxf:properties>
<entry key="signatureParts"
value="{Element}{http://www.w3.org/2003/05/soap-envelope}Body;{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp"/>
</cxf:properties>
</cxf:bus>
<bean id="passwordCallBack" class="our.package.authentication.PasswordCallbackHandler">
<property name="password" value="${password}"/>
<property name="alias" value="${org.apache.ws.security.crypto.merlin.keystore.alias}"/>
</bean>
</beans>
Java:
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap3260sr15fp1-20140110_01(SR15 FP1))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr15-
20131231_180656 (JIT enabled, AOT enabled)
J9VM - 20131231_180656
JIT - r9_20130920_46510ifx3
GC - GA24_Java6_SR15_20131231_1152_B180656)
JCL - 20140107_01
网络逻辑 10.3.6
感谢提示、指点,当然还有 - 如果可能的话 - 回答 ;-)
S.
EJP 请求代码,这里是:
调用本身:
private OurService ourservice;
private Callable<RequestOurRecordResponse> callService(final RequestOurRecordRequest request) {
return new Callable<RequestOurRecordResponse>() {
@Override
public RequestOurRecordResponse call() throws Exception {
try {
return ourService.requestOurRecord(request); // this is line 225.
} catch (Exception e) {
facesMessages.error("technicalError");
log.error("Encountered technical error", e);
return null;
}
}
};
}
生成的网络服务:
package some.package.ws.extract.generated;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.7-b01-
* Generated source version: 2.1
*
*/
@WebService(name = "OurService", targetNamespace = "http://secret/service-v1.0-rc2")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface OurService {
/**
*
* @param requestOurRecordRequest
* @return
* returns some.package.ws.extract.generated.RequestOurRecordResponse
*/
@WebMethod(action = "http://secret/service/RequestOurRecord")
@WebResult(name = "requestOurRecordResponse", targetNamespace = "http://secret/service-v1.0-rc2", partName = "requestOurRecordResponse")
public RequestOurRecordResponse requestOurRecord(
@WebParam(name = "requestOurRecordRequest", targetNamespace = "http://secret/service-v1.0-rc2", partName = "requestOurRecordRequest")
RequestOurRecordRequest requestOurRecordRequest);
}
与:
<http-conf:conduit name="*.http-conduit">
<http-conf:client Connection="Close" />
</http-conf:conduit>
连接(操作系统级别)关闭;但我们仍然有泄漏(上述行为)。
与:
<http-conf:conduit name="*.http-conduit">
<http-conf:client Connection="Keep-Alive" />
</http-conf:conduit>
作为文件描述符的连接(操作系统级别)都在不断上升......
(附加信息:操作系统级别的连接断开(我猜是在超时之后)但文件描述符保持打开状态...)
最佳答案
从我的角度来看,问题与 cxf 配置有关,也许 weblogic + cxf 的相互作用也是一个问题,因为管理连接的是 cxf 组件(请参阅堆栈跟踪)。所以我建议尝试使用不同的保持 Activity 设置(描述了如何设置保持 Activity 状态 here )。不过,这似乎无助于击败打开的文件描述符。
更新:
在对你的问题进行更多思考之后:
at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:266)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1550)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1579)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1520)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1317)
似乎在关闭 http 连接时,cxf 试图取回一些响应代码并为此创建一个套接字,因为这些套接字只是等待永远不会无限期出现的响应,从而造成泄漏。整个流程描述here在简化的客户端工作流程部分下。那么,下一个问题是,tst-cjcsr.just.fgov.be
会回复吗?而且,我的下一个建议是为 http-conf:client
配置 ReceiveTimeout
,如 link 中所述。以上。
关于java - 获取响应代码时文件描述符泄漏。 (cxf, ssl),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40529499/