2016-03-04 91 views
1

我有一個REST服務,某些客戶端出現「連接重置」錯誤。但SOAP是無狀態的,爲什麼它不僅僅是簡單地重新連接並重發請求?它實際上在我的用例中發送了多個消息,但是第一個失敗了,那就是從服務器獲取一些配置數據。這是我需要配置的東西嗎?客戶應該以編程方式嘗試重新發送消息?有些用戶多次嘗試使用相同的結果。使用SOAP時出現「連接重置」

它在過去幾年從未發生過,但現在我得到了一些這個問題的報告。
客戶端用於實現javax.xml.ws.Service,而不僅僅是一個原始套接字。但即使我使用JAX,我也會遇到低級錯誤。它被WebServiceException包裹,但這並不能幫助我解決這個問題。 客戶端都使用Java 8.它是更新66或更新74.

我不能自己重現問題,我只有用戶的日誌文件。

下面是完整的堆棧跟蹤:

javax.xml.ws.WebServiceException: java.net.SocketException: Connection reset 
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(Unknown Source) 
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(Unknown Source) 
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source) 
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source) 
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source) 
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source) 
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source) 
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source) 
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source) 
    at com.sun.xml.internal.ws.client.Stub.process(Unknown Source) 
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source) 
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) 
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) 
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source) 
    at com.sun.proxy.$Proxy31.getLimits(Unknown Source) 
    at xxxxxxxxxxxxx.SOAPServerAdapter.connect(Unknown Source) 
    at xxxxxxxxxxxxxxxxxxxx(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.net.SocketException: Connection reset 
    at java.net.SocketInputStream.read(Unknown Source) 
    at java.net.SocketInputStream.read(Unknown Source) 
    at sun.security.ssl.InputRecord.readFully(Unknown Source) 
    at sun.security.ssl.InputRecord.read(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source) 
    at sun.security.ssl.AppInputStream.read(Unknown Source) 
    at java.io.BufferedInputStream.fill(Unknown Source) 
    at java.io.BufferedInputStream.read1(Unknown Source) 
    at java.io.BufferedInputStream.read(Unknown Source) 
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) 
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) 
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
    at java.net.HttpURLConnection.getResponseCode(Unknown Source) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source) 
    ... 18 more 
+0

退房這個職位http://stackoverflow.com/questions/585599/whats-causing-my-java-net-socketexception-connection-reset –

回答

1

檢查服務器上的負載。看起來像服務器正在關閉連接,因爲負載 - exception on web-service call

+0

難道我看到一些在'卡塔利娜* .log' ?沒有太多的負載。它會在大消息上下降,而不是在第一個上,這幾乎沒有負載。 –

+0

謝謝,原來是「Dual-Stack Lite」的問題。 –

1

原來它是關於IPv4和IPv6。我沒有足夠的知識給出完美的答案,但我可以在這裏張貼他們告訴我的。也許這有助於其他具有相同問題的開發者/用戶。

因此,有些客戶端會出現意外的連接重置,並且與通常的服務器負載無關。

如果客戶端的ISP試圖擺脫IPv4,他們會給每個用戶一個唯一的IPv6地址(請注意,ISP可能會逐步做到這一點)。除了本地使用的IPv4之外,他們實際上不再擁有每個客戶端的IPv4地址,因爲大多數LAN仍然使用諸如192.168.0.0/24之類的東西。

代替典型的IPv4,他們使用一些transaction mechanism(例如Dual-Stack Lite)。那些客戶不能直接訪問IPv4互聯網。因此,如果您的服務器僅支持IPv4,那麼他們可能會遇到類似的問題,他們使用代理時會得到。它們將IPv4數據包封裝在IPv6數據包中,用於通信的某些部分。來自維基百科:「原始的IPv4數據包被恢復,並且NAT在IPv4數據包上執行並被路由到公共IPv4 Internet。」

我真的不知道這裏出了什麼問題。也許NAT耗盡地址/端口或類似的東西。或者該過程需要很長時間,連接由通信中涉及的某個節點重置。

因此,有兩兩件事要做:

  1. 通知有關這些問題的ISP。他們可能會幫助您追蹤確切的問題並幫助他們的客戶,以便他們可以使用您的服務。爲此,您需要知道有「連接重置」問題的用戶的ISP。將它們發送到https://www.whoismyisp.org/或類似的網站。
  2. 儘快升級到IPv6。您的服務器可以同時使用兩種協議版本。