I'm unable to connect mqtt broker service installed in Ubuntu server from out side of the server even Port 1883 is allowed to access out side. Whereas, I'm able to publish and subscribe in server machine.
What could be reason for inability to connect from outside?
msquitto.conf:
allow_anonymous false
password_file /etc/mosquitto/passwd
port 1883
listener 9001
protocol websockets
Note: No logs reported in server machine while connecting through a client machine.
const mqtt = require("mqtt")
const prompt = require('prompt-sync')();
var clientId = `mqtt_${Math.random().toString(16).slice(3)}`
console.log(clientId);
var topic = 'temperature/floor1/room101'
var client = mqtt.connect('mqtt://164.152.312.14:1883'
,{
username: '******',
password: '******'
})
client.on('connect', ()=>{
setInterval(()=>{
if (client.connected==true){
client.publish(topic, sendTemperature())
console.log('Message sent!', sendTemperature())}
}, 500)
})
function sendTemperature(){
var t = {
T: Math.floor(Math.random() * (100 - 10) + 5),
Units: "C"
};
return JSON.stringify(t);
}