mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-22 00:42:47 +08:00
🐛 fix(mqtt): 修复 mqttBrokerAddresses 拼接端口号时重复追加的问题
- 问题根因:mqttBrokerAddresses 中主 broker 地址经过 net.JoinHostPort 再解析再格式化的冗余往返 - 触发条件:config.Host 中已含端口号时,net.JoinHostPort 会再次拼接导致 host:port:port - 修复方式:去掉中间往返,直接使用 mqttFormatHostPort(host, port) 构建地址 - 影响范围:仅 MQTT 数据源的主 broker 地址构造逻辑
This commit is contained in:
@@ -680,7 +680,11 @@ func mqttTransportScheme(config connection.ConnectionConfig) string {
|
||||
|
||||
func mqttBrokerAddresses(config connection.ConnectionConfig) ([]string, error) {
|
||||
hosts := make([]string, 0, 4)
|
||||
if host, port, ok := parseHostPortWithDefault(net.JoinHostPort(strings.TrimSpace(config.Host), strconv.Itoa(config.Port)), defaultMQTTPort); ok && strings.TrimSpace(host) != "" {
|
||||
if host := strings.TrimSpace(config.Host); host != "" {
|
||||
port := config.Port
|
||||
if port <= 0 {
|
||||
port = defaultMQTTPort
|
||||
}
|
||||
hosts = append(hosts, mqttFormatHostPort(host, port))
|
||||
}
|
||||
for _, entry := range config.Hosts {
|
||||
|
||||
Reference in New Issue
Block a user