Mosquitto 1.4.2 Websocket support - websocket

I'm trying to utilize Mosquittos recent update to support websockets in the broker. I'm running Mosquitto v1.4.2 and I've added the following lines to the mosquitto configuration file (mosquitto.conf):
listener 10001 127.0.0.1
protocol websockets
listener 1883
protocol mqtt
When I try and start the broker with the new configuration I get the following :
$ mosquitto -c /etc/mosquitto/mosquitto.conf
Error: Websockets support not available.
Error found at /etc/mosquitto/mosquitto.conf:16.
Error: Unable to open configuration file.
I was under the assumption that version 1.4 and above of Mosquitto has websocket support now (don't have to build from source to enable websocket support like you had to before v1.4) so I'm wondering what I'm missing. Any help on what direction to look to troubleshoot the problem is appreciated.
Edit: Forgot to mention I'm running CentOS6

While the 1.4.x codebase includes Websocket support it has to be enabled at build time and relies on the libwebsocket library.
The builds currently available in the RedHat/Fedora yum repos do not have Webosockets enabled as there is no libwebsocket package available. I assume CentOS is using the same srpms.
See this bugzilla enrty for details: https://bugzilla.redhat.com/show_bug.cgi?id=1197678

you can modify config.mk like this
in config.mk
# Build with websockets support on the broker.
WITH_WEBSOCKETS:=yes
then can you use a config parameter
listener 10001 127.0.0.1
protocol websockets

In the dir mosquitto-1.4.X
edit the file config.mk:
# Build with websockets support on the broker.
WITH_WEBSOCKETS:=yes
Then run in the dir mosquitto-1.4.X
make
sudo make install
Edit the configurations /etc/mosquitto/mosquitto.conf
listener 10001 127.0.0.1
protcol websockets
And restart
mosquitto -c /etc/mosquitto/mosquitto.conf

Related

Unable to connect to Mosquitto broker running on a Windows EC2 Instance from outside the EC2 Instance [duplicate]

I have a virtual machine that is supposed to be the host, which can receive and send data. The first picture is the error that I'm getting on my main machine (from which I'm trying to send data from). The second picture is the mosquitto log on my virtual machine. Also I'm using the default config, which as far as I know can't cause these problems, at least from what I have seen from other examples. I have very little understanding on how all of this works, so any help is appreciated.
What I have tried on the host machine:
Disabling Windows defender
Adding firewall rules for "mosquitto.exe"
Installing mosquitto on a linux machine
Starting with the release of Mosquitto version 2.0.0 (you are running v2.0.2) the default config will only bind to localhost as a move to a more secure default posture.
If you want to be able to access the broker from other machines you will need to explicitly edit the config files to either add a new listener that binds to the external IP address (or 0.0.0.0) or add a bind entry for the default listener.
By default it will also only allow anonymous connections (without username/password) from localhost, to allow anonymous from remote add:
allow_anonymous true
More details can be found in the 2.0 release notes here
You have to run with
mosquitto -c mosquitto.conf
mosquitto.conf, which exists in the folder same with execution file exists (C:\Program Files\mosquitto etc.), have to include following line.
listener 1883 ip_address_of_the_machine(192.168.1.1 etc.)
By default, the Mosquitto broker will only accept connections from clients on the local machine (the server hosting the broker).
Therefore, a custom configuration needs to be used with your instance of Mosquitto in order to accept connections from remote clients.
On your Windows machine, run a text editor as administrator and paste the following text:
listener 1883
allow_anonymous true
This creates a listener on port 1883 and allows anonymous connections. By default the number of connections is infinite. Save the file to "C:\Program Files\Mosquitto" using a file name with the ".conf" extension such as "your_conf_file.conf".
Open a terminal window and navigate to the mosquitto directory. Run the following command:
mosquitto -v -c your_conf_file.conf
where
-c : specify the broker config file.
-v : verbose mode - enable all logging types. This overrides
any logging options given in the config file.
I found I had to add, not only bind_address ip_address but also had to set allow_anonymous true before devices could connect successfully to MQTT. Of course I understand that a better option would be to set user and password on each device. But that's a next step after everything actually works in the minimum configuration.
For those who use mosquitto with homebrew on Mac.
Adding these two lines to /opt/homebrew/Cellar/mosquitto/2.0.15/etc/mosquitto/mosquitto.conf fixed my issue.
allow_anonymous true
listener 1883
you can run it with the included 'no-auth' config file like so:
mosquitto -c /mosquitto-no-auth.conf
I had the same problem while running it inside docker container (generated with docker-compose).
In docker-compose.yml file this is done with:
command: mosquitto -c /mosquitto-no-auth.conf

FastAPI: Error when trying to open a websocket connection after updating uvicorn

When I try to open a websocket connection to my FastAPI server, Uvicorn returns following error after I have updated it from version 0.13.4 (with this version I had no problems) to 0.15.0:
Error in opening handshake
...
websockets.legacy.handshake.check_request(headers)
AttributeError: module 'websockets' has no attribute 'legacy'
Does anyone know what this error exactly means and how to solve it?
when you update the version of unicorn then you need to update the version of websockets
in my case I upgrade unicorn 0.13.4 to 0.14.0 and in the websockets version was 8.1 so I change this 8.1 to 10.0 and it's work
check here for info

Websocket over MQTT by Mosquitto 1.6.10

I have problem with using Websocket on MQTT by Mosquitto.
I'm using raspberry pi as a broker, and want to publish some information, subscribe on web.
Former method (in 1.4.10 version etc.) is to add those two lines
====================
listener 9001
protocol websockets
====================
in /etc/mosquitto/mosquitto.conf or /etc/mosquitto/conf.d/(certain .conf file)
and modify allowance about Websocket in config.mk to [yes]
but in 1.6.10 version, perticularly in raspberrypi, I can't find
the config.mk file so it doesn't works.
Can anybody tell me where's config.mk or if there's any other method to use Websocket on rasp.pi?

Running websocket server with stomp

I have torquebox installed in my jruby on Rails application. And I am experimenting with using stomp + websockets. But I can't tell if the websocket server is even running? I am booting up torquebox in my console with: sudo torquebox run --clustered -b my.ip.address
I keep going through the output from torquebox booting up and the only relevant output I am seeing is this:
[org.torquebox.stomp.as] Initializing TorqueBox STOMP Subsystem
and
[org.projectodd.polyglot.stomp.as] Initializing Polyglot STOMP Subsystem
I don't see anything referencing port 8675, which according to the docs is the port it is supposed to run on. I tried telnet as well and received a 'connection refused' message.
Any help or references would be great. Thanks
Apologies for the dumb question. I just had a typo in my torquebox.yml file. I can now see the output in the bootup that specifies the websocket server is up and I can successfully telnet in.

can't connect to rabbit mq with ruby gem carrot

I am trying to connect to my rabbitmq server.
I am using
require 'carrot'
#client = Carrot.new(:host => 10.xx.xx.xx, :port => 5672)
q = #client.queue("my_queue")
I am getting this error
"#<Carrot::AMQP::Server::ServerDown: Connection reset by peer>"
How do I check if my server is down? and how do I restart it?
rabbitmq-server
Can you help us to help you with some additional info?
What version of Ruby?
What version of RabbitMQ?
Where is your RabbitMQ broker running?
Do you have any kind of firewall preventing you from connecting to the RabbitMQ broker port?
Do you know whetherany security is enabled?
If you have access to the command line of the server where the broker is running, you should be able to see an Erlang process if you execute ps -ef | grep rabbitmq
To start the broker, run
rabbitmq-server
I am able to run your code OK against RabbitMQ 3.0.1 running on my local machine with latest Ruby and Carrot gem, the only correction was that the host IP address needed to be enclosed in double quotes.

Resources