我在運行的Swift服務器上有一些可重現的問題。這是一個使用Kitura的多線程服務器。基礎是:服務器運行一段時間後,下載請求開始需要客戶端重試(通常是三次重試)。客戶端的嘗試導致服務器線程無法終止。在服務器上,下載問題在日誌中顯示爲:爲什麼Swift Kitura Server不能終止某些線程?
[INFO] REQUEST /DownloadFile: ABOUT TO END ...
然後請求永不終止。
在我的服務器相關片段的代碼如下所示:
// <snip>
Log.info(message: "REQUEST \(request.urlURL.path): ABOUT TO END ...")
do {
try self.response.end()
Log.info(message: "REQUEST \(request.urlURL.path): STATUS CODE: \(response.statusCode)")
} catch (let error) {
Log.error(message: "Failed on `end` in failWithError: \(error.localizedDescription); HTTP status code: \(response.statusCode)")
}
Log.info(message: "REQUEST \(request.urlURL.path): COMPLETED")
// <snip>
也就是說,服務器顯然似乎在召喚掛end
(一Kitura方法)。另請參見https://github.com/crspybits/SyncServerII/blob/master/Sources/Server/Setup/RequestHandler.swift#L105
緊隨本次發行前想出了最後一次,我觀察到我的服務器日誌如下:
[2017-07-12T15:31:23.302Z] [ERROR] [HTTPServer.swift:194 listen(listenSocket:socketManager:)] Error accepting client connection: Error code: 5(0x5), ERROR: SSL_accept, code: 5, reason: DH lib
[2017-07-12T15:31:23.604Z] [ERROR] [HTTPServer.swift:194 listen(listenSocket:socketManager:)] Error accepting client connection: Error code: 1(0x1), ERROR: SSL_accept, code: 1, reason: Could not determine error reason.
[2017-07-12T15:31:23.995Z] [ERROR] [HTTPServer.swift:194 listen(listenSocket:socketManager:)] Error accepting client connection: Error code: 1(0x1), ERROR: SSL_accept, code: 1, reason: Could not determine error reason.
[2017-07-12T15:40:32.941Z] [ERROR] [HTTPServer.swift:194 listen(listenSocket:socketManager:)] Error accepting client connection: Error code: 1(0x1), ERROR: SSL_accept, code: 1, reason: Could not determine error reason.
[2017-07-12T15:42:43.000Z] [VERBOSE] [HTTPServerRequest.swift:215 parsingCompleted()] HTTP request from=139.162.78.135; proto=https;
[INFO] REQUEST RECEIVED:/
[2017-07-12T16:32:38.479Z] [ERROR] [HTTPServer.swift:194 listen(listenSocket:socketManager:)] Error accepting client connection: Error code: 1(0x1), ERROR: SSL_accept, code: 1, reason: Could not determine error reason.
我不知道在哪裏,這是從在這個意義上說來,我不知道如果我的客戶之一正在產生這種情況。我沒有明確用「/」向我的服務器發送請求。 (我偶爾會看到來自不是我的客戶端向我的服務器發出的請求 - 這可能是其中之一)。請注意,除了這些日誌消息之外的所有消息都來自Kitura,而不是直接來自我的代碼。我的日誌消息是[INFO] REQUEST RECEIVED: /
。
如果我是一個博彩人,我會說上面的錯誤把我的服務器置於一個狀態,之後,我看到這個下載/重試行爲。
我現在唯一的解決方案是重新啓動服務器。從哪個角度來看問題不會立即發生。
想法?