Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7309159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:43:42+00:00 2026-05-28T23:43:42+00:00

everyone, I met a problem about APNs when I used the code below. I

  • 0

everyone,

I met a problem about APNs when I used the code below.
I have found many kinds of source code to achieve this service

import socket, ssl, json, struct import binascii

deviceToken = 'XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX' 

thePayLoad = {
     'aps': {
          'alert':'Hello world',
          'sound':'default',
          'badge':42,
          },
     'test_data': { 'foo': 'bar' },
     }

theCertfile = 'iphone_ck.pem'  

theHost = ( 'gateway.sandbox.push.apple.com', 2195 )

data = json.dumps( thePayLoad )

deviceToken = deviceToken.replace(' ','') 

byteToken = binascii.unhexlify(deviceToken)

theFormat = '!BH32sH%ds' % len(data) theNotification = struct.pack( theFormat, 0, 32, 

byteToken, len(data), data )

ssl_sock = ssl.wrap_socket( socket.socket( socket.AF_INET, socket.SOCK_STREAM ), certfile = theCertfile ) 

ssl_sock.connect( theHost )

ssl_sock.write( theNotification )

ssl_sock.close()

After I executed the code, and I got an error below.
Everytime when I tried to use PyAPNs on GitHub or APNWrapper on Google
I found that the error at last.
So, I decided to implement by myself.

Traceback (most recent call last):
  File "testAPN.py", line 38, in <module>
    ssl_sock.connect( theHost )
  File "/usr/lib/python2.6/ssl.py", line 309, in connect
    self.do_handshake()
  File "/usr/lib/python2.6/ssl.py", line 293, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:480: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 
alert handshake failure

Could anyone help me to figure out this error or give me some possible directions to
finish this function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:44:50+00:00Added an answer on May 28, 2026 at 11:44 pm

    I think you should try to use APNSWrapper module for this task.

    http://code.google.com/p/apns-python-wrapper/

    It is simple and common use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everyone uses source-code control to manage versions (right?) and this provides some level of
everyone, I have this piece of the code: void foo(int var, int var1) {
Everyone managing open-source-software runs into the problem, that with the time the process of
everyone! i have a question about sessions hopefully someone can help me with. I
I have met an interesting problem while implementing the Observer pattern with C++ and
everyone, I have some question about C++, what do You actually prefer to use
everyone! I couldn't find a tutorial explaining the right way to code this. I
everyone, I have problems when using MVC3 code is as follows public SystemController(IRepository repository)
Everyone knows there is a free source code application available for iPad named ComicFlow,
everyone, thank for your time. Well this my problem (well it's not a probleam

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.