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?
Related
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
On port 8083 I am running Influxdb for which I am even getting the GUI on http://localhost:8083
Now come to kafka, Here I am referring the setup as per https://kafka.apache.org/quickstart
starting the zookeeeper which is in folder /opt/zookeeper-3.4.10 by the command: bin/zkServer.sh start
So zookeeper is started now starting kafka under /opt/kafka_2.11-1.1.0 folder as :
bin/kafka-server-start.sh config/server.properties
create a topic named "test" with a single partition and only one replica:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Topic is created and can be checked in with command :
bin/kafka-topics.sh --list --zookeeper localhost:2181
Uptill here everything is fine and tuned.
Now I need to use "Kafka connect" component to import/export data.
So I am creating a seed data as: echo -e "foo\nbar" > test.txt
Now using connector configuration for "kafka connect" to work :
bin/connect-standalone.sh config/connect-standalone.properties config/connect-file-source.properties config/connect-file-sink.properties
after running above command I am getting : Address already in use
Kafka connect has stopped
I even changed the rest.port=8084 in the /opt/kafka_2.11-1.1.0/config/connect-distributed.properties so as it don't get conflict with influxdb which already on 8083. Still I am getting the same Address already in use,
Kafka connect has stopped as shown in screenshots.
Since you're using Kafka Connect in Standalone mode, you need to change the REST port in config/connect-standalone.properties:
rest.port=18083
To understand more about Standalone vs Distributed you can read the doc here.
Kafka Standalone mode, uses Port 8084 as the Rest API post, by default. Due to this reason, if someone else is using that port already, the process with throw a BindException.
To change the port used above, navigate to the config/connect-standalone.properties file in the Kafka Root directory.
Add the following key value property to change the Port being used for Rest API opening. (Kafka should have included this in the properties file by default, else many developers go nuts trying to find the port mapping used in the standalone mode). Put a different port as you wish.
rest.port=11133
Kafka 3.0.0
Since Kafka Connect is intended to be run as a service, it also provides a REST API for managing connectors. The REST API server can be configured using the listeners configuration option. This field should contain a list of listeners in the following format: protocol://host:port,protocol2://host2:port2. Currently supported protocols are http and https.
For example: listeners= http://localhost:8080,https://localhost:8443
By default, if no listeners are specified, the REST server runs on port 8083 using the HTTP protocol.
More details: https://kafka.apache.org/documentation/#connect_rest
Change the port definition in config/server.properties:
# The port the socket server listens on
port=9092
I am trying to use the rabbitmq as the StompBroker in the WebSocketConfig. Have added the dependencies reactor-core and reactor-net
It works fine when starting up locally (localhost) but when I try to start the project as a docker container (rabbitmq image is correctly built with STOMP plugin), I get below error.
r.io.net.impl.netty.tcp.NettyTcpClient : Failed to connect to /127.0.0.1:61613. Attempting reconnect in 5000ms
I tried setting the setRelayHost("rabbitmq") and setRelayPort(61613) (since rabbitmq is the service name in the docker compose, using it to resolve the host name). No luck still.
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
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.