Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.
MIT License
478 stars 159 forks source link

Connection problem: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:\n error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error #88

Open kevin2486 opened 5 years ago

kevin2486 commented 5 years ago

error while i am doing :- Connection problem: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:\n error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error\n

public function add_product_notification(Request $request){ try { $get_notification = Notification::where('is_send',0)->orderBy('id','ASC')->get(); foreach ($get_notification as $values){ $user = User::where ('status','active')->get(); foreach ($user as $key => $value){ $deviceid = $value['deviceToken']; $push = new PushNotification('apn'); /IOS notification/ $push->setMessage([ 'aps' => [ 'alert' => [ 'title' => 'Eshoppers', 'body' => $values['message'] ], 'sound' => 'default', 'badge' => 1 ], 'extraPayLoad' => [ 'custom' => 'My custom data', ] ]) ->setDevicesToken($deviceid) ->send()->getFeedback(); dd($push->getFeedback()); } } } catch (Exception $e) { return response("", 500); } }

pushnotification.php

return [ 'gcm' => [ 'priority' => 'normal', 'dry_run' => false, 'apiKey' => 'My_ApiKey', ], 'fcm' => [ 'priority' => 'normal', 'dry_run' => false, 'apiKey' => 'AIzaSyA_yPGH_cNAkT3goJMggE_aYhETzDTU9FU',//Legacy server key ], 'apn' => [ 'certificate' =>config_path().'/iosCertificates/Certificates.pem', 'passPhrase' => 'MyPassPhrase', //Optional 'passFile' => DIR . '/iosCertificates/yourKey.pem', //Optional 'dry_run' => true ]

$push = new PushNotification('apn'); when i do var_dump($push); i got this

object(Edujugon\PushNotification\PushNotification)#486 (5) { ["service":protected]=> object(Edujugon\PushNotification\Apn)#487 (10) { ["sandboxUrl":"Edujugon\PushNotification\Apn":private]=> string(41) "ssl://gateway.sandbox.push.apple.com:2195" ["productionUrl":"Edujugon\PushNotification\Apn":private]=> string(33) "ssl://gateway.push.apple.com:2195" ["feedbackSandboxUrl":"Edujugon\PushNotification\Apn":private]=> string(42) "ssl://feedback.sandbox.push.apple.com:2196" ["feedbackProductionUrl":"Edujugon\PushNotification\Apn":private]=> string(34) "ssl://feedback.push.apple.com:2196" ["feedbackUrl":"Edujugon\PushNotification\Apn":private]=> string(42) "ssl://feedback.sandbox.push.apple.com:2196" ["maxAttempts":"Edujugon\PushNotification\Apn":private]=> int(3) ["attempts":"Edujugon\PushNotification\Apn":private]=> int(0) ["url":protected]=> string(41) "ssl://gateway.sandbox.push.apple.com:2195" ["config":protected]=> array(4) { ["certificate"]=> string(66) "/home/eshopper/public_html/config/iosCertificates/Certificates.pem" ["passPhrase"]=> string(12) "MyPassPhrase" ["passFile"]=> string(61) "/home/eshopper/public_html/config/iosCertificates/yourKey.pem" ["dry_run"]=> bool(true) } ["feedback":protected]=> NULL } ["servicesList":protected]=> array(3) { ["gcm"]=> string(29) "Edujugon\PushNotification\Gcm" ["apn"]=> string(29) "Edujugon\PushNotification\Apn" ["fcm"]=> string(29) "Edujugon\PushNotification\Fcm" } ["defaultServiceName":"Edujugon\PushNotification\PushNotification":private]=> string(3) "gcm" ["deviceTokens":protected]=> array(0) { } ["message":protected]=> array(0) { } }

kevin2486 commented 5 years ago

Hey @Edujugon please help me out of this

frofrik commented 4 years ago

I got the same error, turned out I had the wrong certificate. After generating a new one for Apple Push Services it works much better.