Oops. I did not mean to take this "off list". 1) Changing the ConnectionType to CLOSE from KEEP_ALIVE corrected the symptoms from my perspective. 2) I did break out wireshark, and in the "failing circumstances", it appears that the server is closing the socket. The response comes in two packets, and the second one has FIN on. The server's response also indicates "Keep-Alive". 3) The second client request is then being sent, and immediately afterwards we send a FIN (presumably, because we got the exception since the server can no longer write on the socket).
It does indeed sound a like confused server, sending keep-alive and then close the connection. Thanks very much for the help. On Fri, Aug 23, 2013 at 10:03 AM, Daniel Kulp <[email protected]> wrote: > > Any chance you could grab WireShark and monitor the low level connections? > It looks like the server is closing the connection immediately after the > first request and not honoring the keep-alive. > > Older servers (in particular, older Proxy servers) had all kinds of > problems with keep-alive connections. One thing you could try is to turn > off the keep-alives from the client side: > > http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html > > That would force a new HTTP connection for each request which would be > slightly slower, but likely faster than creating all new client proxies and > such. > > Dan > > > > On Aug 23, 2013, at 9:55 AM, David Corbin <[email protected]> wrote: > > Java 1.7.0_25, CXF 2.7.5 > > Well, in all honesty, we're using 2.1.2 in production, but I ran the > simple tests with 2.7.5 because I know we're way out-of-date..... > > > On Fri, Aug 23, 2013 at 8:56 AM, Daniel Kulp <[email protected]> wrote: > >> >> What version of the JDK are you using? There was a similar problem >> related to improper keep-alive handling in some of the JDK's. We have a >> semi-workaround in the latest versions of CXF that should "help" (make sure >> you are using the latest CXF versions), but it really is a problem in the >> JDK. >> >> Dan >> >> >> >> On Aug 23, 2013, at 8:13 AM, David Corbin <[email protected]> wrote: >> >> > I have written a SOAP client using CXF for several third-party SOAP >> > services. I generated java code from the wsdl using wsdl2java. The >> system >> > works, but it's inefficient (I'm creating a new proxy for every call), >> so I >> > thought I'd pool proxy objects. That's when I first noticed the >> problem. >> > >> > After extensive experimentation and hacking, I've found that if I >> attempt >> > to call a service twice with only a short delay, it consistently fails >> with >> > an exception (see below). The "short delay" appears to almost 5 >> seconds. >> > If I put a 5-second delay in between re-uses, I can call it repeatedly >> > without any problems. Now, I know this sounds crazy, but I've boiled it >> > down to pretty simple code. At first I thought it was about re-use of a >> > proxy. But further investigation has shown I have the same problem >> calling >> > different methods on the same service, and it happens if I have one >> proxy >> > or two. >> > >> > I am starting to suspect a server-side problem, but it could be how I'm >> > creating the proxy. >> > >> > So, in my mind, there's either a shared, stateful object (possibly a >> > socket/connection) that multiple proxies use that has a problem, or >> it's a >> > problem strictly on the server side. If it's the former, I'd appreciate >> > help in changing my proxy creation technique. If it's the latter, I'd >> like >> > to really be able to *prove* that it's caused by bad server side >> behaviour. >> > >> > Any help appreciated. >> > Thanks >> > >> > David Corbin >> > >> > >> > ---exception--- >> > >> > org.apache.cxf.interceptor.Fault: Could not send Message. >> > at >> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64) >> > at >> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) >> > at >> org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530) >> > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) >> > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) >> > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) >> > at >> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) >> > at >> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133) >> > at com.sun.proxy.$Proxy46.login(Unknown Source) >> > at SimpleCxfCheck.login(SimpleCxfCheck.java:39) >> > at >> SimpleCxfCheck.testLoadApplicationContext(SimpleCxfCheck.java:23) >> > at SimpleCxfCheck.main(SimpleCxfCheck.java:10) >> > Caused by: java.net.SocketException: SocketException invoking >> > http://somehost.zcorum.com:8996/axis2/services/IncEntitySecurityService >> : >> > Unexpected end of file from server >> > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native >> Method) >> > at >> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) >> > at >> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) >> > at java.lang.reflect.Constructor.newInstance(Constructor.java:526) >> > at >> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1338) >> > at >> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1322) >> > at >> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) >> > at >> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622) >> > at >> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) >> > ... 11 more >> > Caused by: java.net.SocketException: Unexpected end of file from server >> > at >> sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:718) >> > at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:579) >> > at >> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1322) >> > at >> java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) >> > at >> org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:260) >> > at >> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1517) >> > at >> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490) >> > at >> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309) >> > ... 14 more >> > >> > ---end---- >> > >> > ---begin code sample--- >> > >> > import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; >> > >> > import com.incognito.bcc.incentitysecurity.IncEntitySecurityPortType; >> > import com.incognito.bcc.incentitysecurity.Login; >> > import com.incognito.bcc.incentitysecurity.LoginResponse; >> > >> > >> > public class SimpleCxfCheck { >> > public static void main(final String[] args) { >> > new SimpleCxfCheck().run(); >> > } >> > private static final String URL = >> > " >> http://somehost.zcorum.com:8996/axis2/services/IncEntitySecurityService"; >> > >> > public void run() { >> > System.setProperty("org.apache.cxf.stax.allowInsecureParser", >> "1"); >> > final JaxWsProxyFactoryBean factoryBean = new >> JaxWsProxyFactoryBean(); >> > factoryBean.setServiceClass(IncEntitySecurityPortType.class); >> > factoryBean.setAddress(URL); >> > >> > final IncEntitySecurityPortType portType = >> > (IncEntitySecurityPortType) factoryBean.create(); >> > >> > System.out.println(login(portType, "zcuser", "password")); >> > sleep(5000); >> > System.out.println(login(portType, "zcuser", "password")); >> > } >> > >> > private void sleep(final int milliSeconds) { >> > try { >> > Thread.sleep(milliSeconds); >> > } catch (final InterruptedException e) { >> > throw new RuntimeException("FIX ME", e); >> > } >> > } >> > >> > private String login(final IncEntitySecurityPortType portType, >> > final String loginName, final String password) { >> > final Login parameters = new Login(); >> > parameters.setLoginName(loginName); >> > parameters.setPassword(password); >> > >> > final LoginResponse loginResponse = portType.login(parameters); >> > return loginResponse.getAuthorizationToken().getToken(); >> > } >> > } >> > >> > >> > ---end code sample--- >> >> -- >> Daniel Kulp >> [email protected] - http://dankulp.com/blog >> Talend Community Coder - http://coders.talend.com >> >> > > -- > Daniel Kulp > [email protected] - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com > >
