diff --git a/pkg/tuya/client.go b/pkg/tuya/client.go index 277848e7..c6a34d6e 100644 --- a/pkg/tuya/client.go +++ b/pkg/tuya/client.go @@ -6,6 +6,7 @@ import ( "fmt" "net/url" "regexp" + "strings" "sync" "github.com/AlexxIT/go2rtc/pkg/core" @@ -44,7 +45,8 @@ type RecvMessage struct { } func Dial(rawURL string) (core.Producer, error) { - u, err := url.Parse(rawURL) + escapedURL := strings.ReplaceAll(rawURL, "#", "%23") + u, err := url.Parse(escapedURL) if err != nil { return nil, err } @@ -277,8 +279,10 @@ func Dial(rawURL string) (core.Producer, error) { } client.connected.Done(nil) } - default: + case pion.PeerConnectionStateClosed: client.Close(errors.New("webrtc: " + msg.String())) + default: + // client.Close(errors.New("webrtc: " + msg.String())) } } }) diff --git a/pkg/tuya/mqtt.go b/pkg/tuya/mqtt.go index cdf1e8dd..0559e8bc 100644 --- a/pkg/tuya/mqtt.go +++ b/pkg/tuya/mqtt.go @@ -112,7 +112,7 @@ func (c *TuyaMqttClient) Start(hubConfig *MQTTConfig, webrtcConfig *WebRTCConfig SetAutoReconnect(true). SetMaxReconnectInterval(30 * time.Second). SetConnectTimeout(30 * time.Second). - SetKeepAlive(30 * time.Second). + SetKeepAlive(60 * time.Second). SetPingTimeout(20 * time.Second) c.client = mqtt.NewClient(opts)