从.Net消耗CXF Web服务的超时问题

时间:2011-02-08 02:41:01

标签: .net wcf timeout cxf

我正在使用一个.net应用程序,该应用程序使用来自基于CXF的Web服务的数据,并且我遇到了一个奇怪的断开连接问题。虽然我设置了双方可以考虑的所有适当的超时,如果请求的时间超过30秒左右,那么连接就会中断,我会收到以下错误

关于cxf

    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:212)
    at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:510)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:450)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.ctc.wstx.exc.WstxIOException: null
    at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1431)
    at com.ctc.wstx.sw.BaseStreamWriter.writeEndDocument(BaseStreamWriter.java:553)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor$SoapOutEndingInterceptor.handleMessage(SoapOutInterceptor.java:282)
    ... 39 more
Caused by: org.eclipse.jetty.io.EofException
    at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:148)
    at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:92)
    at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:46)
    at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:55)
    at java.util.zip.GZIPOutputStream.writeHeader(GZIPOutputStream.java:123)
    at java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:48)
    at java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:58)
    at org.apache.cxf.transport.common.gzip.GZIPOutInterceptor$GZipThresholdOutputStream.thresholdReached(GZIPOutInterceptor.java:284)
    at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:62)
    at org.apache.cxf.io.CacheAndWriteOutputStream.write(CacheAndWriteOutputStream.java:68)
    at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:100)
    at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:225)
    at com.ctc.wstx.sw.BufferingXmlWriter.close(BufferingXmlWriter.java:198)
    at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1429)
    ... 41 more

.net错误

The underlying connection was closed: The connection was closed unexpectedly. ---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.

这似乎是WCF的默认错误,也是许多不同问题的根源。

如果我使用SoapUi连接到CXF服务,并在其中一个操作中放置一个断点,我可以延迟响应的时间比30秒超时长,并且一旦允许恢复,则respose会在没有问题,它让我相信它的.net方面正在断开连接。

.net客户端配置了所有适当的超时,它们远远大于我正在运行的30秒。

<binding name="serviceBinding" sendTimeout="20:00:00" receiveTimeout="20:00:00" openTimeout="20:00:00" closeTimeout="20:00:00">
    <gzipMessageEncoding />
    <httpTransport manualAddressing="false" decompressionEnabled="False" maxBufferPoolSize="2147483647"     
            maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true"      
            maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
</binding>

还有什么可能会在这里干扰并继续破坏连接吗? gzipMessageEncoding是非标准的,但在请求超过30秒的所有情况下都能正常工作。我非常乐意接受任何建议。

由于

史蒂夫。

1 个答案:

答案 0 :(得分:1)

错误消息不匹配,但您可能需要查看here。异步操作有一个单独的超时,你只能通过代码配置,这可能是你遇到的那个(虽然我说,错误消息似乎不匹配)。实际的文档是here

您可能还想使用WireShark,看看是否可以捕获实际的底层TCP断开连接消息,并查看哪一方实际启动了断开连接。