PushSharp Apns通知错误:'ConnectionError'

Mas*_*edi 5 apn push-notification ios asp.net-mvc-4 pushsharp

我正在使用PushSharp 4.0.10,MVC 4和c#
在Apns代理的OnNotificationFailed事件中,我得到了ConnectionError异常.
更改证书(.p12)文件后突然发生此异常; 在这次改变之前它运作良好.
请告知如何解决此错误.

var certificate = System.IO.File.ReadAllBytes(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Mobile/consumer_dev.p12"));

var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, certificate, "", true);

var apnsBroker = new ApnsServiceBroker(config);

apnsBroker.OnNotificationFailed += (notification, aggregateEx) => {
    aggregateEx.Handle (ex => {
        if (ex is ApnsNotificationException) {
            var notificationException = (ApnsNotificationException)ex;
            var apnsNotification = notificationException.Notification;
            var statusCode = notificationException.ErrorStatusCode;

            Debug.WriteLine(apnsNotification.Identifier + ", " + statusCode);
        } else {
            Debug.WriteLine(ex.InnerException);
        }
        return true;
    });
};

apnsBroker.OnNotificationSucceeded += (notification) => {
    Debug.WriteLine("Apple Notification Sent!");
};

apnsBroker.Start();

foreach (var deviceToken in to)
{
    apnsBroker.QueueNotification(new ApnsNotification
    {
        DeviceToken = deviceToken,
        Payload = JObject.Parse("{\"aps\":" + aps.ToString().Replace('=', ':') + "}")
    });
}

apnsBroker.Stop();
Run Code Online (Sandbox Code Playgroud)

sai*_*a m 0

尝试仅将前两个参数传递给 apnsconfiguration 构造函数,或者删除 validateIsApnsCertificate (bool ) 参数。它对我来说前三个参数工作得很好。

var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production, appleCert, P12Password);
Run Code Online (Sandbox Code Playgroud)