Skip to content

Commit

Permalink
test(mqtt): fix mqtt client connect error
Browse files Browse the repository at this point in the history
  • Loading branch information
ogofly committed Jan 4, 2024
1 parent 7a0bc98 commit 4bf506b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ connector:
mqttBroker:
tcpPort: 1883
wsPort: 8083
# mqtt storage, if left blank, the storage is disabled
# https://github.com/mochi-mqtt/server?tab=readme-ov-file#badger-db
storage:
type: file # file or redis
path: "./embed-mqtt.db" # when type is file
redis:
addr: 127.0.0.1:6379
db: 1
password:
superUsers:
- name: $tio
password: public
Expand Down
2 changes: 1 addition & 1 deletion connector/mqtt/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewClient(cfg config.MqttClientConfig) Client {
opts.SetClientID(cfg.ClientId)
opts.SetUsername(cfg.User)
opts.SetPassword(cfg.Password)
cleanSession := false
cleanSession := true
if cfg.CleanSession != nil {
cleanSession = *cfg.CleanSession
}
Expand Down
5 changes: 3 additions & 2 deletions connector/mqtt/embed/embed_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package embed_test
import (
"context"
"encoding/json"
"ruff.io/tio/connector"
"testing"
"time"

"ruff.io/tio/connector"

"ruff.io/tio/connector/mqtt/client"
"ruff.io/tio/connector/mqtt/embed"

Expand All @@ -25,7 +26,7 @@ func TestEmbedBrokerConnectivity(t *testing.T) {
port := 21883
brk := embed.InitBroker(embed.MochiConfig{
TcpPort: port,
AuthzFn: func(user, password string) bool {
AuthzFn: func(embed.ConnectParams) bool {
return true
},
AclFn: func(user string, topic string, write bool) bool {
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"net/http"
"net/http/httptest"
"os"
connector2 "ruff.io/tio/connector"
"testing"

connector2 "ruff.io/tio/connector"

"ruff.io/tio/connector/mqtt/embed"

"ruff.io/tio/connector/mqtt/client"
Expand Down

0 comments on commit 4bf506b

Please sign in to comment.