Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in APN

andresdkm opened this issue · comments

when I try to send a push by apn I get this error
ErrorException in Apn.php line 283:
stream_socket_client(): Unable to set private key file

I was looking and the error is due to missing

captura de pantalla_2016-10-19_18-11-25

that solution is good?

@andresdkm
Hi,

Is the issue related to sending a push notification or trying to get the APNS feedback (getFeedback method) ? or none of those methods work for you?

Aside from that, Could you check your pem file is correctly created? maybe this post helps you.

Hi

the issue is related to sending a push notification, provided the error occurred, the pem file is generated correctly, after you add the lines that I showed above works correctly.

@andresdkm

Thanks for that bugreport.

I've already updated the code and refactored it a bit.

Please update the package version to v2.1.6.

Could you test it to make sure?

@andresdkm
Hi,

Did you have time to try the new version? Did it work for you?

@andresdkm
Hi, I suppose you aren't facing that issue any more. So I'm closing this..

Anyway, if you think it hasn't been solved yet or you face the same issue in the future let me know and I'll open it again.

Thanks

@Edujugon

I am facing similar issue, my composer.json version is "edujugon/push-notification": "^2.1".

May I add that just yesterday the the same code was working fine.

Any clue ?

My settings

'apn' => [
'certificate' => DIR . '/iosCertificates/'.env('APN_CERTIFICATE', 'apns-dev-cert.pem'),
// 'passPhrase' => '', //Optional
// 'passFile' => DIR . '/iosCertificates/yourKey.pem', //Optional
'dry_run' => true
]

ERROR MESSAGE

{
"message": "stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:14094438:SSL routines:SSL3_READ_BYTES:tlsv1 alert internal error",
"status_code": 500,
"debug": {
"line": 171,
"file": "/vendor/edujugon/push-notification/src/Apn.php",
"class": "ErrorException",
"trace": [
"#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'stream_socket_c...', '/opt/lampp/htdo...', 171, Array)",
"#1/vendor/edujugon/push-notification/src/Apn.php(171): stream_socket_client('ssl://gateway.s...', 0, '', 60, 5, Resource id #357)",
"#2 /vendor/edujugon/push-notification/src/Apn.php(212): Edujugon\PushNotification\Apn->openConnectionAPNS()",
"#3 /vendor/edujugon/push-notification/src/PushNotification.php(163): Edujugon\PushNotification\Apn->send(Array, Array)",
"#4 /app/Http/Controllers/API/Traits/PushNotificationTrait.php(13): Edujugon\PushNotification\PushNotification->send()",
"#5 /app/Http/Controllers/API/DateController.php(112): App\Http\Controllers\API\DateController->sendPushNotification(Array, '3ce6925f43af87f...')",

    ]
}

}

@fahadonline

Hi,
Was that working fine for you before updating to the last version (2.1.6) ?

@Edujugon

Hi,

Thanks for response.
I just integrated it yesterday and tried dry run, which seemed to run and getFeedback.
But today when I executed the same code, it generated above mentioned error.

Any help in resolving it will be very helpful.

BTW I tried with different .pem file and got following errors

{
"message": "stream_socket_client(): Unable to set local cert chain file `config/iosCertificates/aps.pem'; Check that your cafile/capath settings include details of your certificate and its issuer",
"status_code": 500,
"debug": {
"line": 171,
"file": "vendor/edujugon/push-notification/src/Apn.php",
"class": "ErrorException",
"trace": [
"#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'stream_socket_c...', '/opt/lampp/htdo...', 171, Array)",
"#1 vendor/edujugon/push-notification/src/Apn.php(171): stream_socket_client('ssl://gateway.p...', 0, '', 60, 5, Resource id #357)",
"#2 vendor/edujugon/push-notification/src/Apn.php(212): Edujugon\PushNotification\Apn->openConnectionAPNS()",
"#3 vendor/edujugon/push-notification/src/PushNotification.php(163): Edujugon\PushNotification\Apn->send(Array, Array)",
"#4 app/Http/Controllers/API/Traits/PushNotificationTrait.php(13): Edujugon\PushNotification\PushNotification->send()",
"#5 app/Http/Controllers/API/ProspectController.php(87): App\Http\Controllers\API\ProspectController->sendPushNotification(Array, '17f8ca9cba22c71...')",

    ]
}

}

@fahadonline

That's weird because the package hasn't been updated today, it has same code as yesterday..

Today, when you get the error, are you trying same code as yesterday but changing dry_run value? Or also same dry_run value?

Regarding your second error message, that seems to be related to the cert details, no about the package..

In order to be able to reproduce your issue, could you send me the cert file and 1 token you are using? Then I'll try to replicate the issue and check it deeply..

If so, send it to me to edujugon@gmail.com

@Edujugon

Sorry but which by "token" what are you referring to ?
I am using ".pem" certificate without any passPhrase.

I mean any device token which you are sending push notifications

@fahadonline

Have you changed the dry_run value from yesterday? Or you haven't changed anything and yesterday was working and today doesn't..

@Edujugon

Changed no thing, same dry_run value "true"

@fahadonline

I've got your mail with the requested details :)

As soon as I have some free time (maybe tomorrow) I'll try to reproduce the issue and give you an update..

@Edujugon

I have resolved the issue.
I think the main problem was with using certificate without any "passPhrase".
I have got new certificate with short "passPhrase" like 123.
Though "passPhrase" is optional, not using it created problems for me.

Other than that I have used short name for ".pem" file like "apn.pem".
Also instead of copying ".pem" files to "iosCertificates" folder,
I created the new blank ".pem" files in "iosCertificates" folder,
edited and pasted the content of downloaded ".pem" to newly created files.
Also played with "dry_run", switching it between true/false before it finally started working.
Can't remember any other weird stuff that I might have tried :)

@fahadonline
Thank you for your update. :)
Glad to know you solved the issue and now, it works for you.

Anyway, I'll check all those points you mentioned above..