Optimize URL decoding and update MQTT keep-alive

This commit is contained in:
seydx
2025-06-16 14:58:31 +02:00
parent 30c418542c
commit da68101c09
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"regexp" "regexp"
"strings"
"sync" "sync"
"github.com/AlexxIT/go2rtc/pkg/core" "github.com/AlexxIT/go2rtc/pkg/core"
@@ -44,7 +45,8 @@ type RecvMessage struct {
} }
func Dial(rawURL string) (core.Producer, error) { 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 { if err != nil {
return nil, err return nil, err
} }
@@ -277,8 +279,10 @@ func Dial(rawURL string) (core.Producer, error) {
} }
client.connected.Done(nil) client.connected.Done(nil)
} }
default: case pion.PeerConnectionStateClosed:
client.Close(errors.New("webrtc: " + msg.String())) client.Close(errors.New("webrtc: " + msg.String()))
default:
// client.Close(errors.New("webrtc: " + msg.String()))
} }
} }
}) })
+1 -1
View File
@@ -112,7 +112,7 @@ func (c *TuyaMqttClient) Start(hubConfig *MQTTConfig, webrtcConfig *WebRTCConfig
SetAutoReconnect(true). SetAutoReconnect(true).
SetMaxReconnectInterval(30 * time.Second). SetMaxReconnectInterval(30 * time.Second).
SetConnectTimeout(30 * time.Second). SetConnectTimeout(30 * time.Second).
SetKeepAlive(30 * time.Second). SetKeepAlive(60 * time.Second).
SetPingTimeout(20 * time.Second) SetPingTimeout(20 * time.Second)
c.client = mqtt.NewClient(opts) c.client = mqtt.NewClient(opts)