The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
含義:**TCP 連接建立後,服務端主動發送 RST 包斷開**,或服務端進程崩潰導致連接重置。非超時、非證書錯誤、非 4xx/5xx HTTP 狀態碼。
驗證:
`telnet 105.211.91.138 8040` / `nc -zv 105.211.91.138 8040` — 能連通說明網絡通,問題在應用層。
驗證:
- 瀏覽器訪問 WSDL URL,檢查 `
- 服務端配置文件 (`web.config`/`app.config`) 核對 `
- 用 **SoapUI** 導入 WSDL 測試調用,排除客戶端代碼問題。
驗證:
- 查看服務端 **事件查看器 (Windows)** / **journalctl /var/log/syslog (Linux)** / **應用日誌 (log4j/Logback/Serilog)**。
- 啟用 WCF 診斷跟蹤 (`system.diagnostics` + `SvcTraceViewer.exe`)。
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None); // 或 Transport
binding.SendTimeout = TimeSpan.FromMinutes(2);
binding.ReceiveTimeout = TimeSpan.FromMinutes(2);
binding.MaxReceivedMessageSize = 2147483647;
var endpoint = new EndpointAddress("https://105.211.91.138:8040/esb/webservice");
var client = new YourServiceClient(binding, endpoint);
// 可選:啟用 Keep-Alive 避免空閒斷開
((IChannel)client.InnerChannel).OperationTimeout = TimeSpan.FromMinutes(5);
「telnet 先行,WSDL 核對,日誌為王,SoapUI 驗證」—— WebService 連接重置不再無從下手。