A
A
afatsum2017-04-17 12:41:19
PHP
afatsum, 2017-04-17 12:41:19

How to catch an error in stream_socket_client?

There is a line in the code

$result = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx)

When passing it, the error "[error] [php] stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094438:SSL routines:SSL3_READ_BYTES:tlsv1 alert internal error"
I try to catch it with try{}catch (Exception $e){} but the error is not caught and the code ends with a critical error on this line
How to catch this error correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4iloveg, 2017-04-17
@afatsum

@ add to the function. And then throw an exception if $result is not what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question