Skip to content

Commit

Permalink
Revert "Resto MQTT connection to broker"
Browse files Browse the repository at this point in the history
This reverts commit 0ee150e.

We have restore the broker http api, so we are moving back to http for
now.
  • Loading branch information
Flavia Pezoti committed May 7, 2021
1 parent 0760390 commit 5a41df6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions api/sendmqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/labstack/echo"
log "github.com/sirupsen/logrus"
"github.com/topfreegames/arkadiko/httpclient"
)

// SendMqttHandler is the handler responsible for sending messages to mqtt
Expand Down Expand Up @@ -67,18 +68,23 @@ func SendMqttHandler(app *App) func(c echo.Context) error {

err = WithSegment("mqtt", c, func() error {
beforeMqttTime = time.Now()
// Bringing back the MQTT client due to issues with HTTP layer in the broker
if retained {
err = app.MqttClient.SendRetainedMessage(c.Request().Context(), topic, string(b))
} else {
err = app.MqttClient.SendMessage(c.Request().Context(), topic, string(b))
}
httpError := app.HttpClient.SendMessage(
c.Request().Context(), topic, string(b), retained,
)
afterMqttTime = time.Now()
return err
return httpError
})

status := 200
if err != nil {
status = 500
if e, ok := err.(*httpclient.HTTPError); ok {
status = e.StatusCode
}
}
tags := []string{
fmt.Sprintf("error:%t", err != nil),
fmt.Sprintf("status:%d", status),
fmt.Sprintf("retained:%t", retained),
}
if source != "" {
Expand Down

0 comments on commit 5a41df6

Please sign in to comment.