You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
I cannot connect to my Mosquitto broker when using TLS certificate authentication.
This connection issue only happens when using Mosquitto-PHP and using TLS certificate authentication. My CA certificate is stored in the same folder as my php file. The error I get is listed at the bottom of my post: the mosquitto broker outputs a 'Socket error on client' message. I have no problems connecting when I am just using username and password but NOT using TLS certificates. I have a different client on a completely different raspberryPi using python (python paho-mqtt, not using Mosquitto-PHP) that connects to my Mosquitto broker successfully using TLS certificate authentication. Therefore I don't believe the problem is with my Mosquitto broker, I believe the problem is with my code or with Mosquitto-PHP.I have been trying to solve this for about 2 weeks now. Any help would be greatly appreciated!
My code:
use Mosquitto\Client;
define('CLIENT_ID', "pubclient_" + getmypid());
$topic = 'myTestTopic';
$qos = 1;
$myusername = 'myTestUsername';
$mypassword = 'myTestPassword';
/* Construct a new client instance, passing a client ID of “MyClient” /
$client = new Mosquitto\Client(CLIENT_ID);
/ CA certificate is contained in a file /
$client->setTlsCertificates('/var/www/html/ca.crt');
$client->setCredentials($myusername,$mypassword);
$client->setTlsOptions(Mosquitto\Client::SSL_VERIFY_PEER,'tlsv1.2');
$client->setTlsInsecure(true);
$client->onMessage(function($message) {
/ Display the message's topic and payload */
echo $message->topic, "\n", $message->payload, "\n\n";
});
$client->connect('192.168.86.27', 1883);
$client->loop(2000);
$client->disconnect();
Mosquitto Log Output:
1569687780: New connection from 192.168.86.27 on port 1883.
1569687780: Socket error on client , disconnecting.
The text was updated successfully, but these errors were encountered:
I am having the same issue, when using TLS I am unable to connect, it just silently fails. I can connect with the same cert stack (root, cert, key) via mosquitto_pub but will not work when going through the php wrapper. Any help would be appreciated.
Problem:
I cannot connect to my Mosquitto broker when using TLS certificate authentication.
This connection issue only happens when using Mosquitto-PHP and using TLS certificate authentication. My CA certificate is stored in the same folder as my php file. The error I get is listed at the bottom of my post: the mosquitto broker outputs a 'Socket error on client' message. I have no problems connecting when I am just using username and password but NOT using TLS certificates. I have a different client on a completely different raspberryPi using python (python paho-mqtt, not using Mosquitto-PHP) that connects to my Mosquitto broker successfully using TLS certificate authentication. Therefore I don't believe the problem is with my Mosquitto broker, I believe the problem is with my code or with Mosquitto-PHP.I have been trying to solve this for about 2 weeks now. Any help would be greatly appreciated!
My code:
use Mosquitto\Client;
define('CLIENT_ID', "pubclient_" + getmypid());
$topic = 'myTestTopic';
$qos = 1;
$myusername = 'myTestUsername';
$mypassword = 'myTestPassword';
/* Construct a new client instance, passing a client ID of “MyClient” /
$client = new Mosquitto\Client(CLIENT_ID);
/ CA certificate is contained in a file /
$client->setTlsCertificates('/var/www/html/ca.crt');
$client->setCredentials($myusername,$mypassword);
$client->setTlsOptions(Mosquitto\Client::SSL_VERIFY_PEER,'tlsv1.2');
$client->setTlsInsecure(true);
$client->onMessage(function($message) {
/ Display the message's topic and payload */
echo $message->topic, "\n", $message->payload, "\n\n";
});
$client->connect('192.168.86.27', 1883);
$client->loop(2000);
$client->disconnect();
Mosquitto Log Output:
1569687780: New connection from 192.168.86.27 on port 1883.
1569687780: Socket error on client , disconnecting.
The text was updated successfully, but these errors were encountered: