I've set up a mosquitto broker but it refuses to connect over websockets
here is my conf file:
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
listener 1883 0.0.0.0
listener 8008 0.0.0.0
protocol websockets
and I don't have any conf at conf.d
Using the PAHO javascript client I get a ERR_CONNECTION_REFUSED
by the way I'm using debian jessie as OS
-------------------------------------EDIT 1----------------------------------
I've lowered the iptables and it still not working.
The usual way to connect is working (with port 1883)
Here is the output when I start mosquitto
1477788244: mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 10:12:09 +0100) starting
1477788244: Using default config.
1477788244: Opening ipv4 listen socket on port 1883.
1477788244: Opening ipv6 listen socket on port 1883.
The important line in the startup output is here:
1477788244: Using default config.
This says that mosquitto is using it's built in config (only listen on 1883 for native MQTT traffic) and not even reading your config file.
If you just start mosquitto with no command line options this is what is uses, it will not look for a config file in /etc/mosquitto/.
You need to explicitly tell mosquitto where it's config file with the -c option.
mosquitto -c /etc/mosquitto/mosquitto.conf
Depending on how you installed mosquitto you may need to edit the scripts that automatically start it on boot. This is probably in here: /etc/init.d/mosquitto
Related
I'm trying to setup a mosquitto mqtt server on windows using bash on ubuntu on windows because the code I'm try to run is that of Linux but I've been getting this error. I've surfed through the internet for days now and still haven't found a solution,
1588558652: Warning: Mosquitto should not be run as root/administrator.
1588558652: mosquitto version 0.15 (build date 2018-09-05 15:14:14+0000) starting
1588558652: Opening ipv4 listen socket on port 1883.
1588558652: Opening ipv6 listen socket on port 1883.
1588558652: Error: Address already in use
Mind you I'm not a coder so I'm new to all of this. Thanks for helping...
The error is telling you what is wrong: Some other program already has port 1883 open and is using it....thus Mosquitto can't use it.
You can find out which program has port 1883 open by using something like this (Not sure if it works on all Ubuntu's, but works on my v16.04.6 LTS):
netstat -pan | grep 1883
I'm trying to connect/publish from broker to web, but it's not work.
I am already searching on the internet, but cannot find anything to solve it.
example when someone told me to untag bridge_protocol on mosquitto.conf , it's not work but get another error.
my mosquitto version is 1.4.9
I think something need to change on mosquitto.conf
When I try mosquitto -v -c mosquitto.conf
the result is :
mosquitto version 1.4.9
config loaded from mosquitto.conf
opening ipv4 and 6 socket on port 8883
new connection from :11 on port 8883.
socket error on client <unknown>, disconecting.
I can connect/publish from Broker to web.
I'm going to make a guess here...
It looks from the log that you have just changed the default port mosquitto is listening on from 1883 to 8883 most likely with the port configuration option.
You are then trying to connect to this from a webpage using the Paho JavaScript client.
This is failing because while you have changed the port you have not told mosquitto that it needs to use the websocket protocol for that port. This is because the Paho JavaScript client can only use MQTT over WebSockets not native MQTT.
The way to fix this is to reset the default port back to 1883 and then add a listener on port 8883 specifically set up to use WebSockets.
e.g. a mosquitto.conf like this:
port 1883
listener 8883
protocol websockets
I have a mosquitto broker run on a linux behind my company proxy.
I have been configured a bridge to AWS same following: (mosquitto.conf)
connection bridge
address ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com:8089
remote_username admin
remote_password password
topic abc/raspi01 both 0
bridge_cafile /etc/pki/tls/certs/nginx-selfsigned.crt
bridge_insecure false
But when I start mosquitto service with command:
service mosquitto restart
In log file, There are some errors:
1554356888: mosquitto version 1.5.5 starting
1554356888: Config loaded from /etc/mosquitto/mosquitto.conf.
1554356888: Opening ipv4 listen socket on port 1883.
1554356888: Opening ipv6 listen socket on port 1883.
1554356888: Warning: Address family not supported by protocol
1554356888: Connecting bridge bridge (ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com:8089)
1554356888: Error creating bridge: Name or service not known.
1554356888: Warning: Unable to connect to bridge bridge.
1554356901: New connection from 127.0.0.1 on port 1883.
1554356901: New connection from 127.0.0.1 on port 1883.
1554356901: New client connected from 127.0.0.1 as mqtt_fd05fada.b70918 (c1, k60).
1554356901: New client connected from 127.0.0.1 as mqtt_2a3a025d.6c941e (c1, k60).
1554356919: Connecting bridge bridge (ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com:8089)
1554356919: Error creating bridge: Name or service not known.
1554356950: Connecting bridge bridge (ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com:8089)
1554356950: Error creating bridge: Name or service not known.
I things the cause is my company proxy.
I have tried with settings in mosquitto.service, but it not resolve.
[Unit]
Description=Mosquitto MQTT v3.1/v3.1.1 Broker
Documentation=man:mosquitto.conf(5) man:mosquitto(8)
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Environment="HTTPS_PROXY=http://user:pass#proxyhost:8800"
Environment="HTTP_PROXY=http://user:pass#proxyhost:8800"
Environment="NO_PROXY=127.0.0.1,localhost"
Restart=on-failure
[Install]
WantedBy=multi-user.target
Can any body help me? Thank so much.
You can not use a HTTP proxy for MQTT bridge connection (or any native MQTT connection). MQTT is a totally different protocol.
Only MQTT over Websockets would work via a HTTP proxy, but you can not configure mosquitto to run a bridge with MQTT over Websockets.
If one uses HTTP CONNECT before sending connect
in net_mosq.c
rc = connect(*sock, rp->ai_addr, rp->ai_addrlen);
One can accomplish this.
HTTP CONNECT is protocol agnostic, it works on underlying TCP protocol.
I'm in the middle of installing and configuring an XMPP server, using ejabberd on Windows server 2012, running on an EC2 box.
I have opened port 5222 within windows firewall, and added to the security group for the EC2 instance
Custom TCP Rule
TCP
5222
0.0.0.0/0
ejabberd_c2s
Custom TCP Rule
TCP
5222
::/0
ejabberd_c2s
My XMPP logins are not working, and so I've turned to telnet to try and debug - it sees that port 5222 is reporting as closed:
PS C:\WINDOWS\system32> telnet hostname.com 5222
Connecting To hostname.com...Could not open connection to the host, on port 5222: Connect failed
Any guidance or steps towards debugging would be appreciated!
The issue here was in ejabberd's default configuration of "::" as an IP to listen, which forced it to listen only to IPv6.
By updating the ejabbed config to
port: 5222
ip: "0.0.0.0"
module: ejabberd_c2s
I was able to connect via telnet, and able to access the server using XMPP.
I have installed Mosquitto MQTT in one of the EC2 instance(ubuntu) and broker running fine with localhost.
I can able to publish/subscribe in the local machine and as well another EC2 instance (both EC2 in same subnet 172.31.X.X)
Now, i want to connect the broker from a PC outside for (publish/subscribe). So, i tried to configure the broker IP to EC2 instance public IP.
VirtualBox:cat /etc/mosquitto/mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
listener 1883 50.24.39.66
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
VirtualBox:
VirtualBox:sudo mosquitto -c /etc/mosquitto/mosquitto.conf
1495801790: mosquitto version 1.4.8 (build date Fri, 19 Feb 2016 12:03:16 +0100) starting
1495801790: Config loaded from /etc/mosquitto/mosquitto.conf.
1495801790: Opening ipv4 listen socket on port 1883.
1495801790: Error: Cannot assign requested address
carun#carun-VirtualBox:~$
But, while restarting the broker am getting the above error "Cannot assign requested address"
Done so far,
Allowed (inboud/outbound) all access to EC2.
Disabled firewall in EC2
-Allowed all security level access to EC2 security group.
But no luck,
So question,
How to assign a EC2 Public IP to the broker?
How can I access MQTT broker out side of world?
Thanks in advance for your help!
Remove the ip address (50.24.39.66) from the end of listener line (or just remove the whole line) to allow mosquitto to bind to all available IP addresses