Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Unable to establish connection #44

Open
AlanMaxwell opened this issue Feb 25, 2019 · 3 comments
Open

Unable to establish connection #44

AlanMaxwell opened this issue Feb 25, 2019 · 3 comments

Comments

@AlanMaxwell
Copy link

Hello.
I tried to use performed example on Ubuntu and Mac OS, but every time I get the same error:

======> Connecting to gateway.sandbox.push.apple.com:2195...
======> Resolving server hostname...
======> Creating socket...
======> Socket successfully created
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation now in progress (errno: 36)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Trying to connect to x.x.x.x...
======> Could not to connect to: Operation already in progress (errno: 37)
======> Unable to establish connection
======> Connection closing...
======> Connection closed
Could not connect to Apple Push Notification Service: unable to establish connection (errno: 9013)

Instead of x.x.x.x are various IPs.

I tried two ways:
-p12 file
-cert and key .pem files

Tried to use apn-pusher and got the same result.

I tested certificates with the other push-messaging applications and they are working.

What should I do to make it work?

@bouzikas
Copy link

bouzikas commented Jul 7, 2020

Same here. Any workaround?

@AlanMaxwell
Copy link
Author

Same here. Any workaround?

Yes. I just decided to use other libraries.
Now to send a push notification I send http request via "boost asio" functionality to Firebase service. That for "background push" and "push notification".
For sending a VoIP push I configured nghttp2 library and send http2 requests.

@bouzikas
Copy link

bouzikas commented Jul 8, 2020

Funny thing but I found where the problem is. For some reason, if you comment out lines 607 & 608 (610 & 611 for windows) in apn.c:
int sock_flags = fcntl(ctx->sock, F_GETFL, 0);
fcntl(ctx->sock, F_SETFL, sock_flags | O_NONBLOCK);
you got the connection right but there is another issue still (unrelated to flags).

======> Connecting to api.sandbox.push.apple.com:2197...
======> Resolving server hostname...
======> Creating socket...
======> Socket successfully created
======> Trying to connect to x.x.x.x...
======> Connection has been established
======> Initializing SSL connection...
======> Certificate subject: UID=com.XXXXXXXXX, CN=Apple Push Services: com.XXXXXX, OU=XXXXXX, O=XXXXXX., C=US
======> Certificate issuer: C=US, O=Apple Inc., OU=Apple Worldwide Developer Relations, CN=Apple Worldwide Developer Relations Certification Authority
======> Certificate mode: PRODUCTION & SANDBOX (UNIVERSAL) (6)
======> Certificate expires at 2021-08-06 16:04:12
======> ssl: handshake started write:before SSL initialization:unknown
======> ssl: connect:before SSL initialization:(NONE)
======> ssl: connect:SSLv3/TLS write client hello:(NONE)
======> ssl: alert read:SSLv3/TLS write client hello
======> ssl: connect:error
======> Could not initialize SSL connection: SSL_connect() failed: error:00000001:lib(0):func(0):reason(1), Undefined error: 0 (errno: 0):

Is anyone has the same issue?

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

No branches or pull requests

2 participants