Reputation: 824
I have connected GCM
with laravel 5.1
PushNotification through \Zend\Http\
client.
It was working good. But suddenly it stopped working and produce some exceptions
.
My code is like...
$collection = PushNotification::app('appNameAndroid')->to ( $deviceToken );
$collection->adapter->setAdapterParameters(['sslverifypeer' => false]);
$collection->send ( $message );
I also have tried the below codes but none of them are working...
$collection = PushNotification::app('appNameAndroid')->to ( $deviceToken );
$new_client = new \Zend\Http\Client(null, array(
'adapter' => 'Zend\Http\Client\Adapter\Socket',
'sslverifypeer' => false
));
$collection->adapter->setHttpClient($new_client);
$collection->send ( $message );
----------------------------and-----------------------------------
$collection = PushNotification::app('appNameAndroid')->to ( $deviceToken );
$collection->adapter->setAdapterParameters(array(
'ssl'=>array(
'verify_peer' => false,
'verify_peer_name' => false)
));
$collection->send ( $message );
The exceptions are...
exception 'ErrorException' with message 'stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14077102:SSL routines:SSL23_GET_SERVER_HELLO:unsupported protocol' in C:\xampp\htdocs\activ8-webapp\api\vendor\zendframework\zend-http\src\Client\Adapter\Socket.php:281
Next exception 'Zend\Http\Client\Adapter\Exception\RuntimeException' with message 'Unable to enable crypto on TCP connection gcm-http.googleapis.com' in C:\xampp\htdocs\activ8-webapp\api\vendor\zendframework\zend-http\src\Client\Adapter\Socket.php:308
Upvotes: 1
Views: 455
Reputation: 13469
Based from this thread, if your certificate doesn't match, it will fail with that error. Fix your SSL config since it's not PHP's fault. If the SSL config of the server you are connecting to is not correct, you will get an error like this. Try to replace the invalid, misconfigured or self-signed certificate with a good one. You can allow insecure connections via the SMTPOptions
property. It's possible to do this by subclassing the SMTP class in earlier versions, though this is not recommended. Try also changing the app/config/email.php
: smtp
to mail
Sample code snippet found on this link:
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
You can also check this related links:
Hope this helps!
Upvotes: 1