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!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The collection has been marked as complete with regards to additions.

Franco-Vera opened this issue · comments

hi,

Pusharp version 4.0.10
About 10% of daily push notifications are getting this error. until now i think is aleatory...

context: this is a webservices than just send 1 notification for every call. and for the same device sometimes works and sometimes fails.

Mensaje: The collection has been marked as complete with regards to additions.
StackTrace: at System.Collections.Concurrent.BlockingCollection1.TryAddWithNoTimeValidation(T item, Int32 millisecondsTimeout, CancellationToken cancellationToken) at PushSharp.Core.ServiceBroker1.QueueNotification(TNotification notification)
at Connection_Push

By doing many tests I was able to verify that the error occurs when I run the service many times in a very short time.

For example, running the service every one second is no problem, but 10 times in one second the error is generated.

any suggestion?

MY CODE

                       GcmConfiguration config = new GcmConfiguration(fcmkey);
                        config.GcmUrl = GoogleFCM;

                        fcmBroker = new GcmServiceBroker(config);
                        fcmBroker.Start();

                        fcmBroker.OnNotificationFailed += (notification, aggregateEx) =>
                        {
                            aggregateEx.Handle(ex =>
                            { 
                                status.status = "ERROR SENDING PUSH";
                                status.description = ex.Message;
                                return true;
                            });
                        };
                        fcmBroker.OnNotificationSucceeded += (notification) =>
                        {
                            status.status = "Success";
                            status.description = "Send proccess finished";
                        };

                        while (fcmBroker.IsCompleted) { } //my desesperation but not working

                        fcmBroker.QueueNotification(new GcmNotification
                        {
                            RegistrationIds = new List<string> { _dr[0].ToString() },
                            Data = JObject.Parse(jsonconv)
                        });

                        fcmBroker.Stop();

finally found the problem

fcmbroker was created as static variable. Changing this the problem go out,