Node.js 绑定Mosca侦听IP地址?
是否有一种方法专门在特定ip地址/主机名上侦听传入的网络连接?最好是通过在代码中传递ip地址/主机名来动态传递,而不是编辑配置文件 在Mosca的文档中找不到这方面的参考-这就是我发布的原因 谢谢您的时间。它在文档中。创建新的Node.js 绑定Mosca侦听IP地址?,node.js,mqtt,mosca,Node.js,Mqtt,Mosca,是否有一种方法专门在特定ip地址/主机名上侦听传入的网络连接?最好是通过在代码中传递ip地址/主机名来动态传递,而不是编辑配置文件 在Mosca的文档中找不到这方面的参考-这就是我发布的原因 谢谢您的时间。它在文档中。创建新的mosca.Server对象时,可以将主机和端口作为选项对象的一部分传入 var pubsubsettings = { //using ascoltatore type: 'mongo', url: 'mongodb://localhost:27
mosca.Server
对象时,可以将主机
和端口
作为选项对象的一部分传入
var pubsubsettings = {
//using ascoltatore
type: 'mongo',
url: 'mongodb://localhost:27017/mqtt',
pubsubCollection: 'ascoltatori',
mongo: {}
};
var moscaSettings = {
port: 1883, //mosca (mqtt) port
host: "127.0.0.1",
backend: pubsubsettings //pubsubsettings is the object we created above
};
var server = new mosca.Server(moscaSettings); //here we start mosca
server.on('ready', setup); //on init it fires up setup()
// fired when the mqtt server is ready
function setup() {
console.log('Mosca server is up and running')
}