The final part of it came down to a certificate error. Apparently going to an adhoc copy required a new certificate.
Pushsharp connection failure
-
29-03-2022 - |
Question
So I am using push sharp inside of my ASP.NET mvc application and I keep getting a connection failure error. I installed the NUGET package for push sharp so I don't have access to the source code. It took me a while to realize I was getting this error since I wasn't running in debug for a while. First off here is the error code I get.
An unhandled exception of type PushSharp.Apple.ConnectionFailureException occurred in PushShart.Apple.DLL
Additional Information: Maximum number of attempts (3) to connect to gateway.sandbox.push.apple.com:2195 was reached!
This is the code I am using for the push notificaitons. Its pretty simple.
public int samplePush()
{
var push = new PushBroker();
var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Certificates1.p12"));
var settings = new ApplePushChannelSettings(false, appleCert, "1111");
push.RegisterAppleService(settings);
push.QueueNotification(new AppleNotification()
.ForDeviceToken("c49e457bc041dead313f43684a42a0acdc8d4393b229db08e2873849a8a2db22")
.WithAlert("Test push notification")
.WithSound("default")
.WithBadge(7));
push.OnNotificationFailed += push_OnNotificationFailed;
push.StopAllServices();
return 200;
}
I have tried a number of things, first I used multiple certificates including the pem file but none of them give me any errors as far as invalid certificates go.
I also manually opened up port 2195 to allow all connections, I also tried this from multiple connections one of them being my work connection which has worked for push notifications in the past. I am at a loss here of what could be causing this problem.
La solution