Redth / PushSharp

A server-side library for sending Push Notifications to iOS (iPhone/iPad APNS), Android (C2DM and GCM - Google Cloud Message), Windows Phone, Windows 8, Amazon, Blackberry, and (soon) FirefoxOS devices!
Other
4.39k stars 1.52k forks source link

Is Push Sharp Dead? #880

Open kg6zgj opened 6 years ago

kg6zgj commented 6 years ago

What version of PushSharp are you using?

4.0.10

Describe your issue:

Unable to write data to the transport connection basically once an apple notification gets queued that has a bad token the broker becomes unable to send any tokens.

I see PushSharp has not been updated for 2 years... is this a dead library?

What are the steps required to reproduce this issue?

Please provide any Exception Stack Traces

2018-07-18 14:47:44.PM [INFO] APNS-Client[1]: Sending Batch ID=338, Count=1 2018-07-18 14:47:44.PM [INFO] APNS-Client[1]: Can Write? True 2018-07-18 14:47:45.PM [INFO] APNS-CLIENT[1]: Retrying Batch: Batch ID=338, Error=System.IO.IOException: Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state) at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state) 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.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState) at System.Net.Security.SslStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState) at System.IO.Stream.<>c.b__53_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state) at System.Threading.Tasks.TaskFactory1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func5 beginMethod, Func`3 endMethod) at System.IO.Stream.BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count) at PushSharp.Apple.ApnsConnection.d__21.MoveNext() 2018-07-18 14:47:45.PM [INFO] APNS-Client[1]: Disconnecting (Batch ID=338) 2018-07-18 14:47:45.PM [INFO] APNS-Client[1]: Disconnected (Batch ID=338)

ajprala commented 6 years ago

honestly its not "dead" it still works, the issue your describing has been fixed in a variety of Pull Requests, but they have not been merged to master, and i doubt they will be. So you can take the code people have written to fix the issue and build your own version of the push sharp dlls. Hope this helps.

h3smith commented 6 years ago

@Redth really needs to hand the project off to someone that can manage the pull requests.

cvocvo commented 6 years ago

Just saw this comment here that notes @Redth is no longer maintaining the project; +1 to hand the project off to someone (or a few folks) to manage the PR's. https://github.com/Redth/PushSharp/issues/870#issuecomment-394684415

Redth commented 6 years ago

I'm happy to take suggestions for people to work on the various PR's out there...

One thing to note is that until SslStream supports ALPN or someone finds another easy way to do cross platform SSL with ALPN support, there will never be HTTP/2 support for Apple. This is effectively why the project is dead.

The other part of this is, Azure/AWS/* all do a great job at this problem for next to nothing. I'd encourage people to use those services instead.

cvocvo commented 6 years ago

@Redth Hi :grinning: It looks like the (brand new) version of .NET Core 2.1 supports ALPN with SslStream (3+ years on after you made notes about it here: https://github.com/Redth/HttpTwo) :

Still trying to read through it all but there's a few details here if you ctrl+f for SslStream:

Redth commented 6 years ago

Ahh darn, now I'm running out of excuses!

In all seriousness, I'm not sure I'll have the time to implement and maintain all of this. It would certainly be easier if someone else made a HTTP/2 client library.

I also think push sharp really should be rewritten with the new System.IO.Pipeline stuff.

But for some reason I don't have > 24 hours in a day....

ajprala commented 6 years ago

@Redth Ive also looked at, instead of using client certificate (sslstream), using JWT for APNS tokenization. This would drop the need to have ALPN support i think (i could be wrong), and instead use their new auth system. And you "might" be able to use your httptwo client for it. But honestly push sharp has been working well for me, with a few PR's i merged in from the PR list. :D

cvocvo commented 6 years ago

@Redth I hope you don't think I'm throwing you under the bus by any means; the project's large and maintaining / updating is non-trivial. I'm happy it exists at all 😄 there's really no open source replacement that I've found. The pipeline stuff would be nice, but probably not critical for casual users. My knowledge on the HTTP/2 stuff is zero; I just saw they came out with support for it.

I'm in the same camp as @ajprala; generally everything works great. The only things I'd like to maybe see are: -Merge in TLS 1.2 support: https://github.com/Redth/PushSharp/pull/861

Some sort of fix for the service broker -- seems to hang sometimes -- could be the same problem @kg6zgj is having?

@dongkale Jun 19 01:49 please update... ServiceBroker.Stop() function timeout version

public void Stop( int millisecondsTimeout, bool immediately = false )
{
if( !running )
throw new OperationCanceledException( "ServiceBroker has already been signaled to Stop" );
        running = false;

        notifications.CompleteAdding();

        lock( lockWorkers )
        {
            // Kill all workers right away
            if( immediately )
                workers.ForEach( sw => sw.Cancel() );

            var all = ( from sw in workers
                        select sw.WorkerTask ).ToArray();

            Log.Info( "Stopping: Waiting on Tasks" );

            Task.WaitAll( all, millisecondsTimeout );

            Log.Info( "Stopping: Done Waiting on Tasks" );

            workers.Clear();
        }
    }

Maybe some FCM stuff -- but changing the endpoint works fine ( https://github.com/Redth/PushSharp/issues/870#issuecomment-380633174 )

fatim commented 6 years ago

Is there alternative for PushSharp for sending mdm push notifications (device wake up calls)?

h3smith commented 6 years ago

We've mostly migrated to AWS SNS and will be adding in support for Azure. $0.50 to send 1m push notifications is basically free.

Redth commented 6 years ago

THIS ^^^ SO MUCH THIS ^^^

It's SO cheap now to use Azure or AWS to send notifications, just do it this way, please!!!

Almost anyone who argues they can't use these services because something something security, is probably not making a strong case because you shouldn't be sending sensitive data over push notifications ANYWAY, as they go through Apple's/Google's servers regardless. If you have sensitive info to relay, you send a notification that tells the app to securely go fetch that sensitive information.

Folks, I loved making PushSharp, but I really don't have the time to spend on it these days. I'm going to try and do a minor update soon which includes a couple PR's to help mitigate some bugs. I may even try and work in HTTP/2 support for APNS now that SslStream can set ALPN in .NET Core 2.1+, however it's still not a great story for devs (requiring .NET Core 2.1+).

Do yourselves a favour... Go use a third party service to do this, it's super cheap.

jlubeck commented 5 years ago

And if you want completely free, there is also https://onesignal.com/