SudoPlz
SudoPlz

Reputation: 23313

How do I subscribe/publish messages to an mqtt over websockets broker in PHP?

I'm looking for a way to publish/subscribe messages/channels to a RabbitMQ mqtt over websockets broker from php, and I can't find any code, or any good libraries out there.

I found https://github.com/bluerhinos/phpMQTT but it looks like that's for MQTT, and not for MQTT-over-websockets, plus it looks abandoned.

Why is that so hard - I know I'm not the first person looking for that? Any suggestions?

Thank you

Upvotes: 0

Views: 2008

Answers (1)

Josh Woodcock
Josh Woodcock

Reputation: 2803

RabbitMQ uses AMQP not MQTT as a messaging protocol. Anyways there are several PHP RabbitMQ libraries out there that wrap the base phpamqplib library. You can of course use the MQTT plugin in which case the Mosquito library should work but I don't really understand why you would want to use MQTT instead of AMQP unless you have embedded devices publishing to your rabbitmq server. In this case you can still use AMQP for consuming messages with PHP.

My favorite PHP AMQP library is Bunny

Here is a benchmark of the different wrapper libraries out there: https://blog.forma-pro.com/php-amqp-clients-benchmark-them-all-8a4e6adb1a6b

amqp-ext is the fastest but it has to be installed into your php installation so I wouldn't recommend it unless you are already running tens of millions of messages a day and need a small performance gain will improve your costs.

Upvotes: 1

Related Questions