From 76ca6147ec563749ec626586c5409f72b2d4493c Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 15 Aug 2026 14:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D{hi}=E6=8F=A1=E6=89=8B?= =?UTF-8?q?=E6=8B=92=E7=BB=9D=E6=9C=AA=E6=90=BA=E5=B8=A6tenant=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E5=AE=A2=E6=88=B7=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 多租户改造给{hi}握手消息加了必填的tenant字段,但目前的im_webapp(以及 现有iOS/Android客户端)都是标准Tinode SDK,不知道要发这个新字段,导致 每次连接握手都被判定为malformed(400),前端表现为反复断线重连。 改为tenant为空时回退到默认租户"default"(对应迁移脚本里seed的那条记录), 不再直接拒绝;显式携带tenant code的客户端行为不受影响,仅长度校验保留。 --- server/session.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/session.go b/server/session.go index be601f8..a644a83 100644 --- a/server/session.go +++ b/server/session.go @@ -801,9 +801,15 @@ func (s *Session) hello(msg *ClientComMessage) { } tenantCode := strings.TrimSpace(msg.Hi.Tenant) - if tenantCode == "" || len(tenantCode) > 64 { + if tenantCode == "" { + // Clients that predate the tenant-aware protocol (stock Tinode + // webapp/mobile SDKs never send this field) fall back to the + // default tenant rather than being rejected. Clients that do + // send an explicit code are unaffected. + tenantCode = "default" + } else if len(tenantCode) > 64 { s.queueOut(ErrMalformed(msg.Id, "", msg.Timestamp)) - logs.Warn.Println("s.hello: tenant code is missing or invalid", s.sid) + logs.Warn.Println("s.hello: tenant code is invalid", s.sid) return } if store.Tenants == nil {