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.38k stars 1.53k forks source link

WnsServiceConnection.Send is not thread safe #619

Closed jackita closed 8 years ago

jackita commented 8 years ago

Hi all,

I notice that if I send more than one notification very close using the same instance of WnsServiceBroker, I get an error from Microsoft, it's status is "ChannelThrottled". Furthermore, if I instance a new WnsServiceBroker for each notification, all works fine.

Redth commented 8 years ago

This is interesting and weird. I have tried a minor change (using a new instance of HttpClient for each notification), that's the only real 'difference' between creating a new broker instance i can think of.

jackita commented 8 years ago

Yes this works but it isn't a good solution because instance a new connection for each windows push notification. The matter is regarding the handling of GetAccessToken. Infact if you have multiple pushs to send you could have multiple call to the GetAccessToken that cause the failure.

Redth commented 8 years ago

@jackita I'm not sure what you mean. There were some other changes to WNS to make the GetAccessToken method not called over and over.

Redth commented 8 years ago

I believe this is fixed, please ask to reopen if you believe otherwise.