Creating a bridge between mosquitto MQTT and EMQX using NodeJS











up vote
-1
down vote

favorite












I have set up mosquitto with NodeJs and EMQX with the NodeJs in 2 different applications. I want to create a bridge between both my MQTT clients and send and receive values from both ends.



Tried creating a bridge using WebSocket Options in my MQTT npm package.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


My EMQ connection with NodeJs.



var client = mqtt.connect('ws://100.84.81.28:8083/mqtt');









share|improve this question
























  • Bridges are created between brokers, not clients. The mosquitto.conf docs explain how to set it up to bridge to another broker
    – hardillb
    yesterday










  • Yes. Thats what i meant. I want to include my mosquitto.conf file in my nodejs code. How do i do that?
    – Abishek Ranka
    yesterday










  • OK, so look at the man (mosquitto.org/man/mosquitto-conf-5.html) page for the conf file. Have a go and you can ask specific questions if you get stuck
    – hardillb
    yesterday










  • I use my mosquitto.conf file in my terminal and it works absolutely fine. Not able to include it in my nodejs where i am stuck. Not able to create a bridge between mosquitto and EMQx
    – Abishek Ranka
    yesterday












  • @hardillb - Is my way of including the websocket URL right in my mosquitto options in the above code? Or is there any other way?
    – Abishek Ranka
    yesterday

















up vote
-1
down vote

favorite












I have set up mosquitto with NodeJs and EMQX with the NodeJs in 2 different applications. I want to create a bridge between both my MQTT clients and send and receive values from both ends.



Tried creating a bridge using WebSocket Options in my MQTT npm package.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


My EMQ connection with NodeJs.



var client = mqtt.connect('ws://100.84.81.28:8083/mqtt');









share|improve this question
























  • Bridges are created between brokers, not clients. The mosquitto.conf docs explain how to set it up to bridge to another broker
    – hardillb
    yesterday










  • Yes. Thats what i meant. I want to include my mosquitto.conf file in my nodejs code. How do i do that?
    – Abishek Ranka
    yesterday










  • OK, so look at the man (mosquitto.org/man/mosquitto-conf-5.html) page for the conf file. Have a go and you can ask specific questions if you get stuck
    – hardillb
    yesterday










  • I use my mosquitto.conf file in my terminal and it works absolutely fine. Not able to include it in my nodejs where i am stuck. Not able to create a bridge between mosquitto and EMQx
    – Abishek Ranka
    yesterday












  • @hardillb - Is my way of including the websocket URL right in my mosquitto options in the above code? Or is there any other way?
    – Abishek Ranka
    yesterday















up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have set up mosquitto with NodeJs and EMQX with the NodeJs in 2 different applications. I want to create a bridge between both my MQTT clients and send and receive values from both ends.



Tried creating a bridge using WebSocket Options in my MQTT npm package.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


My EMQ connection with NodeJs.



var client = mqtt.connect('ws://100.84.81.28:8083/mqtt');









share|improve this question















I have set up mosquitto with NodeJs and EMQX with the NodeJs in 2 different applications. I want to create a bridge between both my MQTT clients and send and receive values from both ends.



Tried creating a bridge using WebSocket Options in my MQTT npm package.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


My EMQ connection with NodeJs.



var client = mqtt.connect('ws://100.84.81.28:8083/mqtt');






mqtt mosquitto emq






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago

























asked yesterday









Abishek Ranka

32




32












  • Bridges are created between brokers, not clients. The mosquitto.conf docs explain how to set it up to bridge to another broker
    – hardillb
    yesterday










  • Yes. Thats what i meant. I want to include my mosquitto.conf file in my nodejs code. How do i do that?
    – Abishek Ranka
    yesterday










  • OK, so look at the man (mosquitto.org/man/mosquitto-conf-5.html) page for the conf file. Have a go and you can ask specific questions if you get stuck
    – hardillb
    yesterday










  • I use my mosquitto.conf file in my terminal and it works absolutely fine. Not able to include it in my nodejs where i am stuck. Not able to create a bridge between mosquitto and EMQx
    – Abishek Ranka
    yesterday












  • @hardillb - Is my way of including the websocket URL right in my mosquitto options in the above code? Or is there any other way?
    – Abishek Ranka
    yesterday




















  • Bridges are created between brokers, not clients. The mosquitto.conf docs explain how to set it up to bridge to another broker
    – hardillb
    yesterday










  • Yes. Thats what i meant. I want to include my mosquitto.conf file in my nodejs code. How do i do that?
    – Abishek Ranka
    yesterday










  • OK, so look at the man (mosquitto.org/man/mosquitto-conf-5.html) page for the conf file. Have a go and you can ask specific questions if you get stuck
    – hardillb
    yesterday










  • I use my mosquitto.conf file in my terminal and it works absolutely fine. Not able to include it in my nodejs where i am stuck. Not able to create a bridge between mosquitto and EMQx
    – Abishek Ranka
    yesterday












  • @hardillb - Is my way of including the websocket URL right in my mosquitto options in the above code? Or is there any other way?
    – Abishek Ranka
    yesterday


















Bridges are created between brokers, not clients. The mosquitto.conf docs explain how to set it up to bridge to another broker
– hardillb
yesterday




Bridges are created between brokers, not clients. The mosquitto.conf docs explain how to set it up to bridge to another broker
– hardillb
yesterday












Yes. Thats what i meant. I want to include my mosquitto.conf file in my nodejs code. How do i do that?
– Abishek Ranka
yesterday




Yes. Thats what i meant. I want to include my mosquitto.conf file in my nodejs code. How do i do that?
– Abishek Ranka
yesterday












OK, so look at the man (mosquitto.org/man/mosquitto-conf-5.html) page for the conf file. Have a go and you can ask specific questions if you get stuck
– hardillb
yesterday




OK, so look at the man (mosquitto.org/man/mosquitto-conf-5.html) page for the conf file. Have a go and you can ask specific questions if you get stuck
– hardillb
yesterday












I use my mosquitto.conf file in my terminal and it works absolutely fine. Not able to include it in my nodejs where i am stuck. Not able to create a bridge between mosquitto and EMQx
– Abishek Ranka
yesterday






I use my mosquitto.conf file in my terminal and it works absolutely fine. Not able to include it in my nodejs where i am stuck. Not able to create a bridge between mosquitto and EMQx
– Abishek Ranka
yesterday














@hardillb - Is my way of including the websocket URL right in my mosquitto options in the above code? Or is there any other way?
– Abishek Ranka
yesterday






@hardillb - Is my way of including the websocket URL right in my mosquitto options in the above code? Or is there any other way?
– Abishek Ranka
yesterday














1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










As said in the comments, bridges are something you have to configure in the broker, not the client.



The following will not work, you have told the client library to connect to the broker using native MQTT with the mqtt:// url prefix. This means it will totally ignore the wsOptions block in settings object.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


Also you can't have the client try to connect to 2 separate brokers at once (You can have 2 separate client instances).



To configure a bridge you need to look at the mosquitto.conf doc, you will need to run your own instance of mosquitto, you can not use test.mosquitto.org as you can not change it's config. The bridge needs to be made using native MQTT, not MQTT over websockets.






share|improve this answer





















  • Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
    – Abishek Ranka
    12 hours ago










  • And also is it possible to send files from mosquitto to EMQX and vice versa?
    – Abishek Ranka
    12 hours ago










  • New Problem, new question
    – hardillb
    6 hours ago











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204341%2fcreating-a-bridge-between-mosquitto-mqtt-and-emqx-using-nodejs%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










As said in the comments, bridges are something you have to configure in the broker, not the client.



The following will not work, you have told the client library to connect to the broker using native MQTT with the mqtt:// url prefix. This means it will totally ignore the wsOptions block in settings object.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


Also you can't have the client try to connect to 2 separate brokers at once (You can have 2 separate client instances).



To configure a bridge you need to look at the mosquitto.conf doc, you will need to run your own instance of mosquitto, you can not use test.mosquitto.org as you can not change it's config. The bridge needs to be made using native MQTT, not MQTT over websockets.






share|improve this answer





















  • Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
    – Abishek Ranka
    12 hours ago










  • And also is it possible to send files from mosquitto to EMQX and vice versa?
    – Abishek Ranka
    12 hours ago










  • New Problem, new question
    – hardillb
    6 hours ago















up vote
0
down vote



accepted










As said in the comments, bridges are something you have to configure in the broker, not the client.



The following will not work, you have told the client library to connect to the broker using native MQTT with the mqtt:// url prefix. This means it will totally ignore the wsOptions block in settings object.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


Also you can't have the client try to connect to 2 separate brokers at once (You can have 2 separate client instances).



To configure a bridge you need to look at the mosquitto.conf doc, you will need to run your own instance of mosquitto, you can not use test.mosquitto.org as you can not change it's config. The bridge needs to be made using native MQTT, not MQTT over websockets.






share|improve this answer





















  • Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
    – Abishek Ranka
    12 hours ago










  • And also is it possible to send files from mosquitto to EMQX and vice versa?
    – Abishek Ranka
    12 hours ago










  • New Problem, new question
    – hardillb
    6 hours ago













up vote
0
down vote



accepted







up vote
0
down vote



accepted






As said in the comments, bridges are something you have to configure in the broker, not the client.



The following will not work, you have told the client library to connect to the broker using native MQTT with the mqtt:// url prefix. This means it will totally ignore the wsOptions block in settings object.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


Also you can't have the client try to connect to 2 separate brokers at once (You can have 2 separate client instances).



To configure a bridge you need to look at the mosquitto.conf doc, you will need to run your own instance of mosquitto, you can not use test.mosquitto.org as you can not change it's config. The bridge needs to be made using native MQTT, not MQTT over websockets.






share|improve this answer












As said in the comments, bridges are something you have to configure in the broker, not the client.



The following will not work, you have told the client library to connect to the broker using native MQTT with the mqtt:// url prefix. This means it will totally ignore the wsOptions block in settings object.



var client = mqtt.connect('mqtt://test.mosquitto.org', {
clientId: 'mqttjs_6fa3a7ee3d',
wsOptions: {
host: '100.84.81.28',
port: 8083,
path: '/mqtt'
}
});


Also you can't have the client try to connect to 2 separate brokers at once (You can have 2 separate client instances).



To configure a bridge you need to look at the mosquitto.conf doc, you will need to run your own instance of mosquitto, you can not use test.mosquitto.org as you can not change it's config. The bridge needs to be made using native MQTT, not MQTT over websockets.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









hardillb

22.9k62959




22.9k62959












  • Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
    – Abishek Ranka
    12 hours ago










  • And also is it possible to send files from mosquitto to EMQX and vice versa?
    – Abishek Ranka
    12 hours ago










  • New Problem, new question
    – hardillb
    6 hours ago


















  • Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
    – Abishek Ranka
    12 hours ago










  • And also is it possible to send files from mosquitto to EMQX and vice versa?
    – Abishek Ranka
    12 hours ago










  • New Problem, new question
    – hardillb
    6 hours ago
















Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
– Abishek Ranka
12 hours ago




Thank you so much!! I have 2 separate node applications. Any idea how to implement Native MQTT into my nodejs code? Please share if you got any code snippets.
– Abishek Ranka
12 hours ago












And also is it possible to send files from mosquitto to EMQX and vice versa?
– Abishek Ranka
12 hours ago




And also is it possible to send files from mosquitto to EMQX and vice versa?
– Abishek Ranka
12 hours ago












New Problem, new question
– hardillb
6 hours ago




New Problem, new question
– hardillb
6 hours ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204341%2fcreating-a-bridge-between-mosquitto-mqtt-and-emqx-using-nodejs%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)