bluerhinos / phpMQTT

a simple php class to connect/publish/subscribe to a MQTT broker
Other
773 stars 460 forks source link

TLSv1.2 Error:Connection failed! (Error: 0x00 0x00) #135

Open shuhadaharris opened 2 years ago

shuhadaharris commented 2 years ago

Hi,

I'm using the script to connect to Mosquitto Broker using TLS1.2.

My issue is that, the connection seems to be unstable. I run my PHP code and received some data for a while then it throws me some PHP Warning but I had to re-run the code in order to get the data back.

This line gives me the error: $this->socket = stream_socket_client('tlsv1.2://' . $this->address . ':' . $this->port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $socketContext);

Warning/Error Messages received:

  1. PHP Warning: stream_socket_client(): Filename cannot be empty in \phpMQTT.php line 293

    • $this->socket = stream_socket_client('tlsv1.2://..........
  2. PHP Warning: failed loading cafile stream: `' in \phpMQTT.php line 293

    • $this->socket = stream_socket_client('tlsv1.2://..........
  3. PHP Warning: stream_socket_client(): Failed to enable crypto in \phpMQTT.php on line 293

    • $this->socket = stream_socket_client('tlsv1.2://..........
  4. Error:Connection failed! (Error: 0x00 0x00)

It would be good if anyone can give me any idea on why this happens and how do I fix this.