C#マルチスレッドWindowsサービスでのプッシュ通知の送信に問題があります。
APNSに多くの通知を送信すると、一部のスレッドが例外をスローします。
Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.Write(Byte[] buffer) ...
私は16スレッドのthreadPoolを持っており、各スレッドはAppleへの接続を開きます。
私が試したので、タイムアウトではありません:sslStream.WriteTimeout = 60000;
私も試しました:Client.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.KeepAlive, false);
送信開始時に接続が閉じられていません。
編集:私はすべてのデータが送信されたと思います、そしてAppleは突然接続を閉じます。
この例外の原因について知っていますか?どのように解決しますか?
必要に応じてコードを提供できます。
ご回答ありがとうございます!