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.52k forks source link

ApnsRealTest.cs problem Apns notification error: 'ConnectionError' #788

Open edwardgonen opened 7 years ago

edwardgonen commented 7 years ago

What version of PushSharp are you using?

Latest downloaded from here (GitHub)

Describe your issue:

Always when trying to run the Apns_send_Single it fails with the "connectionError" exception at broker.OnNotificationFailed:

        var succeeded = 0;
        var failed = 0;
        var attempted = 0;

        var config = new ApnsConfiguration (ApnsConfiguration.ApnsServerEnvironment.Sandbox, Settings.Instance.ApnsCertificateFile, Settings.Instance.ApnsCertificatePassword);
        var broker = new ApnsServiceBroker (config);
        broker.OnNotificationFailed += (notification, exception) => {
            **failed++;**
        };
        broker.OnNotificationSucceeded += (notification) => {
            succeeded++;
        };
        broker.Start ();

        foreach (var dt in Settings.Instance.ApnsDeviceTokens) {
            attempted++;
            broker.QueueNotification (new ApnsNotification {
                DeviceToken = dt,
                Payload = JObject.Parse ("{ \"aps\" : { \"alert\" : \"Hello PushSharp!\" } }")
            });
        }

        broker.Stop ();

What are the steps required to reproduce this issue?

Please provide any Exception Stack Traces

Here is my setting.json file, of course with modified values:

"apns_cert_file" : "iPhonePushCert.p12",
"apns_cert_pwd" : "mypassword",
"apns_device_tokens" : 
[
"qdgesggm spbk55sk s59smtjh eotmgjw9 3skrnxir peitmsjt elxuekt8 dit7tut5",
"8354a517 96l765b9 cef56f76 d6971b11 4bef3378 fdad54a4 e993e411 111f0bc3"
],
grifon102 commented 7 years ago

I have problem to

grifon102 commented 7 years ago

I have also stopped to take notice

SiddiquiImran commented 7 years ago

I found one think i am not getting this error if i am sending notification to only one device.

But if i try to send notification to more the one device using foreach like: foreach (var deviceToken in MY_REGISTRATION_IDS) { SendiOSMsg(deviceToken); }

I am getting this error.

any help ? :(

SiddiquiImran commented 7 years ago

this is my log:

Apple Notification Failed: DeviceToken=3e77e5ba33c0a45f4a4f71c7dd5aedf89184f463f00d3b6e35293c9196dc4e94,Payload={ "aps": { "alert": { "body": "Test! Bitte kurze Whatsapp an mich, wenn angekommen ;) Gruß CR", "title": "GB 1976" } }, "ModuleId": null, "ActivationId": 0, "image": "icon", "notId": 727395098 }, Code=ConnectionError, IsDeviceRegistrationIdValid = True, exception: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 17.188.142.148:2195 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PushSharp.Apple.ApnsConnection.d__25.MoveNext()

bidianqing commented 7 years ago

IIS Express is Succeeded and IIS is Failed