mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-29 13:49:28 +08:00
Fix MQTT port
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
parent
bbc66553b2
commit
cc50880217
@ -7,9 +7,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/mainflux/mainflux/db"
|
"github.com/mainflux/mainflux/db"
|
||||||
"github.com/mainflux/mainflux/models"
|
"github.com/mainflux/mainflux/models"
|
||||||
|
"github.com/mainflux/mainflux/config"
|
||||||
|
|
||||||
"github.com/krylovsk/gosenml"
|
"github.com/krylovsk/gosenml"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
@ -48,10 +50,10 @@ var msgHandler mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message)
|
|||||||
fmt.Println(status)
|
fmt.Println(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mqc *MqttConn) MqttSub() {
|
func (mqc *MqttConn) MqttSub(cfg config.Config) {
|
||||||
// Create a ClientOptions struct setting the broker address, clientid, turn
|
// Create a ClientOptions struct setting the broker address, clientid, turn
|
||||||
// off trace output and set the default message handler
|
// off trace output and set the default message handler
|
||||||
mqc.Opts = mqtt.NewClientOptions().AddBroker("tcp://localhost:1883")
|
mqc.Opts = mqtt.NewClientOptions().AddBroker("tcp://" + cfg.MqttHost + ":" + strconv.Itoa(cfg.MqttPort))
|
||||||
mqc.Opts.SetClientID("mainflux")
|
mqc.Opts.SetClientID("mainflux")
|
||||||
mqc.Opts.SetDefaultPublishHandler(msgHandler)
|
mqc.Opts.SetDefaultPublishHandler(msgHandler)
|
||||||
|
|
||||||
|
@ -17,4 +17,4 @@ mongoDatabase = "mainflux"
|
|||||||
|
|
||||||
# MQTT
|
# MQTT
|
||||||
mqttHost = "emqttd"
|
mqttHost = "emqttd"
|
||||||
mqttPort = 1833
|
mqttPort = 1883
|
||||||
|
@ -17,4 +17,4 @@ mongoDatabase = "mainflux"
|
|||||||
|
|
||||||
# MQTT
|
# MQTT
|
||||||
mqttHost = "localhost"
|
mqttHost = "localhost"
|
||||||
mqttPort = 1833
|
mqttPort = 1883
|
||||||
|
2
main.go
2
main.go
@ -123,7 +123,7 @@ func main() {
|
|||||||
// MQTT
|
// MQTT
|
||||||
mqc := new(clients.MqttConn)
|
mqc := new(clients.MqttConn)
|
||||||
//Sub to everything comming on all channels of all devices
|
//Sub to everything comming on all channels of all devices
|
||||||
mqc.MqttSub()
|
mqc.MqttSub(cfg)
|
||||||
|
|
||||||
// Serve HTTP
|
// Serve HTTP
|
||||||
go servers.HttpServer(cfg)
|
go servers.HttpServer(cfg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user