Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

payload error #7

Open
carlhung opened this issue Apr 26, 2017 · 9 comments
Open

payload error #7

carlhung opened this issue Apr 26, 2017 · 9 comments

Comments

@carlhung
Copy link

carlhung commented Apr 26, 2017

Hey,
sorry to disturb you.
I installed swift complier of version 3.1.1 on Ubuntu in order to run the code.
certificate is good although I found some problem. also, installed http2, etc. all the components I need.
now, I can successfully use the certificate.
but I encountered another error message from curl.

there is the code I used:
// the token is work, i used other application to test the token.
let token = "8fcf2f3a21102db657da053870781bb4164bce650ab8afd77de24ce52f796848"
let push = APNS(withCerts: APNSCertificate(certPath: "/home/carl/swift/time/pem/crt.pem",
keyPath: "/home/carl/swift/time/pem/key.pem
)
)
let payload = APNSPayload(withText: "Test")
push.send(payload: payload, to: token)

I got following error:

  • Trying 17.188.166.27...
  • Connected to api.development.push.apple.com (17.188.166.27) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: none
  • SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
  • ALPN, server accepted to use h2
  • Server certificate:
  • subject: CN=api.development.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
  • start date: Jun 19 01:49:43 2015 GMT
  • expire date: Jul 18 01:49:43 2017 GMT
  • subjectAltName: api.development.push.apple.com matched
  • issuer: CN=Apple IST CA 2 - G1; OU=Certification Authority; O=Apple Inc.; C=US
  • SSL certificate verify ok.
  • Using HTTP2, server supports multi-use
  • Connection state changed (HTTP/2 confirmed)
  • TCP_NODELAY set
  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
  • Using Stream ID: 1 (easy handle 0x7f2254021530)

POST /3/device/8fcf2f3a21102db657da053870781bb4164bce650ab8afd77de24ce52f796848 HTTP/1.1
Host: api.development.push.apple.com
Accept: application/json
Content-Type: application/json
apns-priority: 10
apns-expiration: 0
Content-Length: 6

< HTTP/2.0 200
HTTP/2.0 200
< apns-id:F6303094-AA99-B6EF-D603-03A751EB391C
apns-id:F6303094-AA99-B6EF-D603-03A751EB391C

<

  • Connection #0 to host api.development.push.apple.com left intact
    ret = CURLcode(rawValue: 0)

------------------------------the error message can be different, some time:-----------------------
...
Content-Length: 0

< HTTP/2.0 400
HTTP/2.0 400
< apns-id:0D66D5A3-2909-D13A-F1DD-0F9234DA883F
apns-id:0D66D5A3-2909-D13A-F1DD-0F9234DA883F

  • HTTP error before end of send, stop sending
    <
    {"reason":"PayloadEmpty"}* Closing connection 0
    ret = CURLcode(rawValue: 0)

-------------------------------------sometime:---------------------------------------------------
Content-Length: 3

< HTTP/2.0 200
HTTP/2.0 200
< apns-id:9C2EC37B-4DEF-ACFF-3C20-A3C491C6A3BC
apns-id:9C2EC37B-4DEF-ACFF-3C20-A3C491C6A3BC

<

  • Connection #0 to host api.development.push.apple.com left intact
    ret = CURLcode(rawValue: 0)

but the way, I found a bug if the file names of the key and certificate have more than two dots like:
xxx.xxx.pem // that causes unable to open the file.
xxx.pem // that is work.

@matteocrippa
Copy link
Member

@carlhung thank you for your feedback I fixed documentation first to remove double dots inside name file issue ( https://github.com/boostcode/Tori-APNS/blob/master/README.md ).

When it raises Connection #0 as far as I remember it means that it works fine, but I think the issue is with PUSH UUID format, try to remove the minus inside

@carlhung
Copy link
Author

the UUID I didn't provide. as I read the document from Apple. apns-id can be ignored. and apple apn server will provide one. the UUID above was returned by apple. and I also tried to modify the payload format as I saw "{"reason":"PayloadEmpty"}", still couldn't make it.

@matteocrippa
Copy link
Member

let's try to debug in this way: are certificates for development env?

@carlhung
Copy link
Author

yes, for development.

@carlhung
Copy link
Author

carlhung commented Apr 27, 2017

I googled about this error, some said it is because of the version of curl.
but i tried to install few version i still couldn't make it run.
there is a new module for vopar, it calls vapor-apns deriving from your repositories. I read from the package.swift in the module.
and I also saw you fork CCurl from IBM and modified. I am thinking if it is because of the curl that you are using? as I am using the IBM one. should i add ccurl from your git to my package.swift?
but i checked again, that your ccurl and the IBM's ccurl the only different is in Package.swift:
.Brew("curl --with-openssl --with-nghttp2"), // yours
.Brew("curl"), // IBM's

thanks.

@matteocrippa
Copy link
Member

Yep at that time it was needed to force the http2 protocol to add that tweak

@carlhung
Copy link
Author

carlhung commented Apr 27, 2017

but the project i am already using IBM's. but how can I change to use yours? as KITURA's so many modules IBM's CCurl.

@matteocrippa
Copy link
Member

It is a still pending issue that one swift package manager, it force you to use only library, you can't use more than one.
Probably they managed to upgrade the lib and now it is not compatible, I should have to test it, but in those day I have no spare time to

@carlhung
Copy link
Author

anyway, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants