From ab399bcef2f6215824956eba07d58d94079d69d8 Mon Sep 17 00:00:00 2001 From: Denis Suchok Date: Thu, 22 Jul 2021 00:23:17 +0300 Subject: [PATCH 1/3] Fixed Tls version for Windows 10 and Windows 7. --- Firebase.Cloud.Messaging/FcmConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firebase.Cloud.Messaging/FcmConnection.cs b/Firebase.Cloud.Messaging/FcmConnection.cs index 2afb99a..97c9996 100644 --- a/Firebase.Cloud.Messaging/FcmConnection.cs +++ b/Firebase.Cloud.Messaging/FcmConnection.cs @@ -32,7 +32,7 @@ public async Task ConnectAsync() client.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, 60); sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null); - await sslStream.AuthenticateAsClientAsync(host, null, SslProtocols.Tls13, false).ConfigureAwait(false); + await sslStream.AuthenticateAsClientAsync(host, null, SslProtocols.Tls13 | SslProtocols.Tls12, false).ConfigureAwait(false); } public async Task SendAsync(byte[] data, CancellationToken cancellationToken) From f0877e6d569865b05133c4375c73463e30eb8fb3 Mon Sep 17 00:00:00 2001 From: Denis Suchok Date: Sat, 24 Jul 2021 23:27:26 +0300 Subject: [PATCH 2/3] Fixed for System.NotSupportedException (Memory stream is not expandable). --- Firebase.Cloud.Messaging/FcmListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firebase.Cloud.Messaging/FcmListener.cs b/Firebase.Cloud.Messaging/FcmListener.cs index 1d3a6b5..69aabac 100644 --- a/Firebase.Cloud.Messaging/FcmListener.cs +++ b/Firebase.Cloud.Messaging/FcmListener.cs @@ -316,7 +316,8 @@ private void GetNextMessage() byte[] unreadBytes = new byte[unreadBytesCount]; dataStream.Read(unreadBytes, 0, unreadBytes.Length); - dataStream = new MemoryStream(unreadBytes); + dataStream = new MemoryStream(unreadBytes.Length); + dataStream.Write(unreadBytes, 0, unreadBytes.Length); } else { From 0f7e3de53bd0c5bfbfe2ae9cf79313b9d9a6e840 Mon Sep 17 00:00:00 2001 From: Denis Suchok Date: Thu, 9 Dec 2021 18:53:25 +0300 Subject: [PATCH 3/3] Fixed high CPU usage when sslStream instantly returns 0 bytes read. --- Firebase.Cloud.Messaging/FcmConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firebase.Cloud.Messaging/FcmConnection.cs b/Firebase.Cloud.Messaging/FcmConnection.cs index 97c9996..efd7b8a 100644 --- a/Firebase.Cloud.Messaging/FcmConnection.cs +++ b/Firebase.Cloud.Messaging/FcmConnection.cs @@ -68,7 +68,7 @@ public async Task ReceiveAsync(CancellationToken cancellationToken) } // it seems that if the underlying socket is disconnected no exception is thrown - if (client.Connected == false) + if (!client.Connected || bytesRead == 0) { throw new SocketException(1); }