HiveMQ systemctl service not listening to port - linux

I am trying to set up HiveMQ on my Amazon EC2 instance (ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170414) using this guide: http://www.hivemq.com/docs/hivemq/latest/#hivemqdocs_installation_for_specific_operating_systems
After installing I can succesfully run HiveMQ using:
Change directory to HiveMQ directory cd /opt/hivemq
Execute startup script ./bin/run.sh
HiveMQ will start running, and listening to port 1883 and I can connect and subscribe to the broker.
When I run HiveMQ as a systemctl service:
For Debian-based linux like Debian, Ubuntu, Raspbian using systemd systemctl enable hivemq
It starts as a service withoutany issues
However, when running netstat -an|grep 1883 it does not show any activity. HiveMQ do not seem to listen to any ports and I can not connect with my MQTT client. What could be the issue?

without any additional information my guess would be an issue with permissions.
chown -R hivemq:hivemq /opt/hivemq (changing the owner of the hivemq folder to the hivemq user)
will resolve this issue

Related

cannot connect mongodb with ssh when ran as service

I am running mongodb on AWS.
When I do sudo service mongod start mongo runs at port 27017 and the data communication between the app and the db works flawlessly. However, I cannot connect to it with MongoDB Compass SSH connection. It says Error creating SSH Tunnel: (SSH) Channel open failure: Connection refused.
When I check netstat port 27017 is being listened fine. Also I cannot launch another instance of mongo because the port is already being listened.
Funny thing is that if I stop the serivce by going sudo service mongod stop and if I don't run it as a service but just run it on the terminal by going sudo mongod, I can connect via SSH just fine. Why is this?

Redis not reading configuration file

I am trying to setup a redis server following this guide to provide shared sessions for my Elastic Beanstalk.
I've installed redis on a new ec2 instance, and it's working fine, locally. However, when I tried to connect the project from my Beanstalk to my redis server, I am getting a "connection refused" error.
After some poking around, I found out that my redis only listens to local (I think?)
netstat -l
tcp 0 0 localhost:6379 *:* LISTEN
I have already out bind 0.0.0.0 to /etc/redis/6379.conf, but I suspect that redis is not reading the same configuration file.
My questions:
How do I check if my redis server is actually loading the configuration file? I tried typing spam into the file and sudo service redis_6379 restart expecting errors, but redis starts normally.
Is there another way for me to configure redis to listen to all connections from my VPC?
Edit: Found my answer.
To find out what configuration file is loaded: redis-cli -p 6379 info server
There's 2 parts of the configuration file that I need to change, firstly bind 0.0.0.0 and comment the bind 127.0.0.1 that comes after.
On Linux Ubuntu server 20.04 LTS I was running into a similar issue after reboot of the EC2 server, for me what resolved it (my nodeJs app was running as Ubuntu user I needed to make that path available) was to add to the PATH within /etc/crontab by:
sudo nano /etc/crontab and just comment out the original path in there so you can switch back if required (mine was: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ) and replace it with:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/ubuntu/.nvm/versions/node/v12.20.0/bin and that error disappeared for me

Mongodb Management Service Error, Failure dialing host

I've downloaded MMS by using this command
curl -OL https://mms.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.deb
Installed it by using sudo
sudo dpkg -i mongodb-mms-monitoring-agent_latest_amd64.deb
And edited /monitoring-agent.config file which located in
/etc/mongodb-mms
It was working Just fine Until I've started my mongod rplSet by adding --Fork flag, and by using this command
sudo mongod --fork --port 27017 --dbpath /mydbpath --logpath /mylogpath/mongodb.log --replSet Rplname
After starting the services using the above command, my MMS started showing that the host is Unreachable, and that following msg, in all of the members.
Task failure `hostIpAddr`. Err: `Failure determining IPv4 address for `myDnsAdd.cloudapp.net`. Err: `myDnsAdd.cloudapp.net: no such host` at monitoring-agent/components/task.go:221 at monitoring-agent/components/worker.go:153 at monitoring-agent/components/worker.go:224 at monitoring-agent/components/worker.go:236 at pkg/runtime/proc.c:1445`
I've edited the hosts file, and added the hosts ips and hostnames.
Opened the 443 port, and tried to start mmms with --system flag like this
sudo start mongodb-mms-monitoring-agent --system
But still, Host is Unreachable. I got access list on the mongoport (:27017) is it beacuse of this? if so what IP should I add to that access list?
Best,
If your OS is Ubuntu 14.04, then this link should be interesting for you:
https://jira.mongodb.org/browse/MMS-2202
Basically it says that it is a bug in glibc and the solution for this guy was to update Ubuntu to version 14.10.

mosquitto-client obtain refused connection

I want to use MQTT protocol using mosquitto library.
First of all, I want to do some test installing mosquitto-clients
sudo apt-get install mosquitto-clients
This program provides two "method":
mosquitto_pub
mosquitto_sub
Following this instructions I'm trying to submit new topic:
mosquitto_sub -d -t newtopic/test
using default host/port [localhost/1883].
I obtain:
Error: Connection refused
Is too generic as error.. can anyone help me?
Could be is a firewall problem? In this case, how can I check if is this the problem?
I'm using linux ubuntu ( 3.8.0-42-generic #62~precise1-Ubuntu)
nb same behaviour writing custom program using libmosquitto.
Just edit Mosquitto configuration file ( /etc/mosquitto/conf.d/mosquitto.conf ) adding these lines...
allow_anonymous true
listener 1883 0.0.0.0
... and restart Mosquitto (as service or not).
$ sudo service mosquitto restart
or
$ mosquitto --verbose --config-file /etc/mosquitto/conf.d/mosquitto.conf
As informed here, since v.1.7 allow_anonymous defaulted to false.
It is also useful to check log messages ( /var/log/mosquitto/mosquitto.log ).
Finally, run Mosquitto subscriber/publisher using --host (-h) parameter and the host IP address (get if from ifconfig or ip -color addr command).
The default host:port combination for mosquitto_pub/sub is localhost:1883. If you do not have a broker running on your local computer then it will not be able to connect of course.
The solution is to either run the broker on your local computer, or to tell the utilities where to connect. For example:
mosquitto_sub -t newtopic/test -h test.mosquitto.org
None of the other answers worked for me. In my case, I had upgraded from mosquitto 1.X to mosquitto 2.0, which requires a new configuration to be added to your mosquitto.conf:
listener 1883
For clients other than localhost to connect (ie, via Docker)
For future googlers:
You can use a public host as mentioned above, but to start a local mosquitto broker, first make sure you have installed mosquitto in addition to mosquitto_sub. You can then start up the mosquitto broker by simply running the following:
mosquitto
I experienced the same issue, for me it was in upgrading mosquitto for mqtt v5 support:
$ mosquitto --version
mosquitto version 2.0.14
mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.
However, the upgraded broker no longer supported anonymous connections:
$ mosquitto_pub -t mytopic -m "Hello World"
Connection error: Connection Refused: not authorised.
Error: The connection was refused.
This is probably a better default, but less friendly when experimenting.
To configure the broker to allow anonymous connections:
$ cat /etc/mosquitto/conf.d/standard.conf
listener 1883
protocol mqtt
allow_anonymous true
$ sudo systemctl restart mosquitto.service
Then, hey presto 🎩🐇:
$ mosquitto_pub -t mytopic -m "Hello World"
This is happening because you have installed only mosquitto clients on your system and not installed mosquitto on your system. please execute below command to install the MQTT Broker.
sudo apt-get install mosquitto
source:
connection attempt failed bytesofgigabytes.com
Be sure Your mosquitto service installed and correctly running.
for install : sudo apt-get install mosquitto
after install : sudo service mosquitto stop , sudo service mosquitto start
I had setup a username and password for my broker. Therefore had to use that while using mosquitto sub:
mosquitto_sub -u username -P password -t newtopic/test -h test.mosquitto.org

NRPE remote host setup on amazon ec2

I have been trying to monitor a remote server using Nagios-Nrpe.
The remote host is the Amazon Ec2 instance where I have installed npre daemon on xinetd.
I have added my nagios server IP to "only-from" property in /etc/xinet.d/nrpe file.
I have added the entry in /etc/services.
I have made changes in iptables also.
I have added an entry for TCP port 5666 in my security group too.
These commands work properly:
$ netstat -at | grep nrpe
$usr/local/nagios/libexec/check_nrpe -H localhost
I have setup the nagios server and nrpe_check plugin on my local machine.
But whenever I am doing:
/usr/local/nagios/libexec/check_nrpe -H <"amazon-ec2-IP-address">
I get the following error:
connect to address <"amazon-ec2-IP-address"> port 5666: Connection refused ......
connect to host <"amazon-ec2-IP-address"> port 5666: Connection refused
I have tried making the nrpe client on another linux on my LAN and the command worked, but not for Amazon Ec2.
If anyone has the solution for this issue, please do share ASAP.
Make sure you have,
Opened up port 5666 in the Security Group linked to the EC2-instance.

Resources