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');
mqtt mosquitto emq
|
show 1 more comment
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');
mqtt mosquitto emq
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
|
show 1 more comment
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');
mqtt mosquitto emq
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
mqtt mosquitto emq
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
|
show 1 more comment
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
|
show 1 more comment
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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