IOS推送消息程序从2014-04-16开始连接不上APNS服务器gateway.sandbox.push.apple.com,报错信息为“从传输流收到意外的 EOF 或 0 个字节”,请问谁能知道具体是什么原因?十分感谢!

解决方案 »

  1.   

    解决了吗? 我也是那天出现了这个问题, 用的是APNS-Sharp的库,请问有解决方案了吗?
      

  2.   

    试一下SSL发送一下,好像我这边也不行,但是SSL是可以的!static void Main(string[] args)
            {
                //测试
                string hostIP = "gateway.sandbox.push.apple.com";//
                //正式
                //string hostIP = "gateway.push.apple.com";
                int port = 2195;
                string password = "123456";//
                string certificatepath = "aps_development.p12";
                //string certificatepath = "aps_production.p12";
                //这里面证书路径一定要注意了
                string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"App_Code/", certificatepath);
                certificate = new X509Certificate2(System.IO.File.ReadAllBytes(p12Filename), password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);            certificates = new X509CertificateCollection();
                certificates.Add(certificate);
                TcpClient apnsClient = new TcpClient();
                apnsClient.Connect(hostIP, port);            SslStream apnsStream = new SslStream(apnsClient.GetStream(), false, new RemoteCertificateValidationCallback(validateServerCertificate), new LocalCertificateSelectionCallback(selectLocalCertificate));            try
                {
                    //SSL可以换不同的试试
                    apnsStream.AuthenticateAsClient(hostIP, certificates, System.Security.Authentication.SslProtocols.Default, false);
                }
                catch (System.Security.Authentication.AuthenticationException ex)
                {
                    Console.WriteLine("error:" + ex.Message);
                }            if (!apnsStream.IsMutuallyAuthenticated)
                {
                    Console.WriteLine("error:" + "Ssl Stream Failed to Authenticate");
                }            if (!apnsStream.CanWrite)
                {
                    Console.WriteLine("error:" + "Ssl Stream is not Writable");
                }
                Byte[] message = ToBytes();
                try
                {
                    apnsStream.Write(message);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                apnsStream.Close();
                Console.WriteLine("success:" + "Ssl Stream is Writable" + ",message is " + Convert.ToBase64String(message));
                Console.ReadLine();
            }
      

  3.   

    我也发现这个问题,但之后看了上面的代码
    //
    apnsStream.AuthenticateAsClient(hostIP, certificates, System.Security.Authentication.SslProtocols.Default, false);SslProtocols.Default,用这个测试可以
      

  4.   

    APPLE技术支持回邮件了,没有一点指导意义。就是让去以下是文档关于推送信息的一些常见难题的解决方案文档<Troubleshooting Push Notifications>:
    https://developer.apple.com/library/ios/technotes/tn2265/_index.html跪求各位兄弟,有无找到解决的方案,问题都出现一周了,很闹心呀
      

  5.   

    下载profile在装下
      

  6.   

    apnsStream.AuthenticateAsClient(hostIP, certificates, System.Security.Authentication.SslProtocols.Default, false);修改了以上的地方,问题还是存在
      

  7.   

    我用的是JdSoft.Apns.Notifications也是差不多16号开始发送不出去,用的测试的证书,现在还没有找到解决方案有已经解决的麻烦在这里共享下,谢谢您了!
      

  8.   

    跟换成https有没有关系呢
      

  9.   

    我也遇到这个问题,搞了两天,终于在这个帖子得到解决。证书没问题,不知道苹果做了什么改动。我是把 System.Security.Authentication.SslProtocols.Ssl3 改为 System.Security.Authentication.SslProtocols.Default 就可以了。很奇怪,具体原因未明。