Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apns notification error: 'ConnectionError' #855

Open
BookHsu opened this issue Oct 19, 2017 · 4 comments
Open

Apns notification error: 'ConnectionError' #855

BookHsu opened this issue Oct 19, 2017 · 4 comments

Comments

@BookHsu
Copy link

BookHsu commented Oct 19, 2017

What version of PushSharp are you using?

version 4.0.10.0
using c# console app

Describe your issue:

I have about 240 devices that need to be pushed,
But some of them are faulty device tokens,
I found a problem, when I use the for-loop to push all the devices,
if the push to the wrong device token, the subsequent full device token even if it is correct will appear the same error.

What are the steps required to reproduce this issue?

    public void Send(IEnumerable<UUIDModel> SendDevice, string Title, string MessageContent, int QueueID, string Lang)
     {
        string strCertFile = "FileName";
     

        var appleCert = File.ReadAllBytes(string.Format("{0}\\cert\\{1}", AppDomain.CurrentDomain.BaseDirectory, strCertFile));
        ApnsConfiguration pushConfig = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production, appleCert, "myPassword");
        ApnsServiceBroker apnsBroker = new ApnsServiceBroker(pushConfig);
        apnsBroker.OnNotificationFailed += NotificationFailed;
        apnsBroker.OnNotificationSucceeded += NotificationSucceeded;
        apnsBroker.Start();
        foreach (var item in SendDevice)
        {
            JObject jObject = JObject.FromObject(new
            {
                aps = new { alert = new { title = Title, body = MessageContent }, sound = "default", badge = 1 }
            });

            apnsBroker.QueueNotification(new ApnsNotification(item.DeviceToken, jObject));
        }
        apnsBroker.Stop();

    }

Please provide any Exception Stack Traces

This is the wrong devicetoken
18:30:12 0.0.0.0 N/A NotificationFailed-APN Token=<36651c38 15054f04 feaa0571 87d52587 f5b62d63 733f68f8 b3d5ee2f 01ac6f8b>
18:30:12 0.0.0.0 N/A NotificationFailed-APN Apns notification error: 'ConnectionError'
18:30:12 0.0.0.0 N/A NotificationFailed-APN Invalid DeviceToken
This is the correct device token
18:30:13 0.0.0.0 N/A NotificationFailed-APN Token=3c39c9dd23a8da53077c5ee104276d7372eafaf446f9371f1ece116b1f3c37ee
18:30:13 0.0.0.0 N/A NotificationFailed-APN Apns notification error: 'ConnectionError'
18:30:13 0.0.0.0 N/A NotificationFailed-APN Invalid DeviceToke

If I do a push on a single correct device token, I can normally receive a push message.

@sultanwork77
Copy link

Any update on this. Am also getting same problem. If one device i get ConnectionError then all are falling under that. Even the correct device tokenid its not able to send the notification.

@opacitychris
Copy link

I am also getting connection error problems.

  1. I confirmed and even re-created my certificates to be safe
  2. switched between production and sanbox
  3. tried different servers
  4. saw some people had TLS related SSL problems and tried some options there

no luck, returns Code=ConnectionError

@dickverweij
Copy link

Any update on this? Having the same problems..

@opacitychris
Copy link

@dickverweij Yes, I posted on a different git thread about how i resolved.

My solution was found in debugging.

While i got "connection error" as the main error, debugging the exception to the InnerException showed me an Invalid Token error.

My token though was perfectly fine from the phone and I confirmed that it was the right one (production vs sandbox)

However, when stripping the spaces from the token, everything worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants