我的应用程序刚刚准备好在 App Store 上销售,但我的生产设备(已从 App Store 安装应用程序的设备)都没有收到推送通知。当我尝试向生产设备发送推送通知时,我收到此错误:
"The credentials supplied to the package were not recognized"
(System.ComponentModel.Win32Exception)
此异常在内部抛出并陷入无限循环:
它在ApplePushChannel.cs
文件的第 539 行抛出:
try
{
stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates,
System.Security.Authentication.SslProtocols.Ssl3, false);
//stream.AuthenticateAsClient(this.appleSettings.Host);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
}
这是 Visual Studio 输出中应用程序的输出:
...
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
...(it keeps getting thrown until I stop it manually)
以下是我尝试过的事情:
- 仔细检查我正在尝试的设备 ID 是否已使用生产设备令牌注册。
- 吊销并重新生成 APNS 生产证书,将其与私钥一起导出到新
.p12
文件,然后使用新证书再次尝试。(我在开发推送通知方面遇到了同样的问题,这解决了我的问题) - 将 SSL 协议从 更改
Ssl3
为Tls
. (前几天协议版本有问题,暂时解决了一个问题。应该不需要这个,但我得到的错误与我之前得到的错误相同) - 检查我实际上是在尝试使用生产证书而不是开发服务器/证书连接到生产服务器。
- 检查我是否可以直接访问 APNS 服务器(我的 ASP.NET 应用程序位于我的 Mac 上的 Parallels VM Windows 8.1 中,这是我的 Mac 的输出,只是为了避免混淆:
(终端输出) 编辑:我在 ping 沙箱服务器,我已经 ping 生产服务器,我验证我也可以连接到它,所以这不是问题。
can$ sudo nmap -p 2195 gateway.sandbox.push.apple.com
Starting Nmap 6.40-2 ( http://nmap.org ) at 2014-04-28 00:06 EEST
Nmap scan report for gateway.sandbox.push.apple.com (17.149.34.189)
Host is up (0.49s latency).
Other addresses for gateway.sandbox.push.apple.com (not scanned): 17.149.34.187 17.149.34.188
PORT STATE SERVICE
2195/tcp open unknown
为什么 PushSharp 不与 APNS 服务器协商?