summaryrefslogtreecommitdiffstats
path: root/matterclient/matterclient.go
diff options
context:
space:
mode:
Diffstat (limited to 'matterclient/matterclient.go')
-rw-r--r--matterclient/matterclient.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go
index ff3036b4..f3e188a0 100644
--- a/matterclient/matterclient.go
+++ b/matterclient/matterclient.go
@@ -197,11 +197,6 @@ func (m *MMClient) WsReceiver() {
for {
var rawMsg json.RawMessage
var err error
- if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil {
- m.log.Error("error:", err)
- // reconnect
- m.Login()
- }
if !m.WsConnected {
continue
@@ -211,6 +206,12 @@ func (m *MMClient) WsReceiver() {
return
}
+ if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil {
+ m.log.Error("error:", err)
+ // reconnect
+ m.Login()
+ }
+
var event model.WebSocketEvent
if err := json.Unmarshal(rawMsg, &event); err == nil && event.IsValid() {
m.log.Debugf("WsReceiver: %#v", event)