我正在使用一個偉大的庫PushSharp來向許多客戶端設備發送Apple推送通知&。 自上週以來,我們經常面臨連接問題。在這些問題發生之前,我們的託管環境沒有任何更新或任何更新。爲什麼我的與Apple APNS的TCP連接掛起並強行斷開
的問題是在這條線在ApnsConnection.cs:
stream.AuthenticateAsClient (Configuration.Host, certificates, System.Security.Authentication.SslProtocols.Tls, false);
有時TCP連接停止響應在這裏。約21分鐘後,下面的異常被拋出:
System.IO.IOException: Unable to read data from the connection:
An existing connection was forcibly closed by the remote host. --->
System.Net.Sockets.SocketException: An existing connection was forcibly
closed by the remote host
從PushSharp的記錄顯示以下內容:
13:11:33 | PushServiceV2 | APNS-Client[7]: Sending Batch ID=1, Count=21
13:11:33 | PushServiceV2 | APNS-Client[7]: Connecting (Batch ID=1)
13:11:33 | PushServiceV2 | APNS-Client[7]: client.ConnectAsync
13:11:33 | PushServiceV2 | APNS-Client[7]: client.Client.SetSocketOption
13:11:33 | PushServiceV2 | APNS-Client[7]: SetSocketKeepAliveValues
13:11:33 | PushServiceV2 | APNS-Client[7]: Configuration.SkipSsl:False
13:11:33 | PushServiceV2 | APNS-Client[7]: Create our ssl stream
13:11:33 | PushServiceV2 | APNS-Client[7]: stream.AuthenticateAsClient
13:32:03 | PushServiceV2 | APNS-CLIENT[7]: Send Batch Error: Batch ID=1, Error=System.IO.IOException:
正如你可以看到,它的「連接之前需要21分鐘被強行關閉遠程主機。」
要解決任何問題,我開始檢查一批推送通知的發送後,我斷開人TCP連接。此外,我增加了批次之間的時間到5分鐘。如果蘋果因爲建立了許多連接而斷開我的連接,我想這應該可以解決它。但事實並非如此。
- 所有批次的90%都成功發送和接收,所以證書應該是正確的;
- 我會定期檢查反饋服務並刪除不活動的設備;
- 我有一個不同的位置/網絡上的不同的開發機器上同樣的問題。
有沒有人就如何進一步調查此問題的任何線索或提示?
非常感謝提前!