{"record":{"id":"0dfd95ad80867b08","repo":"chenhg5/cc-connect","slug":"yuanbao-not-connected","errorCode":null,"errorMessage":"yuanbao: not connected","messagePattern":"yuanbao: not connected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/yuanbao/platform.go","lineNumber":416,"sourceCode":"\tif !ok {\n\t\treturn fmt.Errorf(\"yuanbao: invalid reply context type %T\", rctx)\n\t}\n\tif content == \"\" {\n\t\treturn nil\n\t}\n\tcontent = core.StripMarkdown(content)\n\tp.startReplyHeartbeat(rc.chatID)\n\tdefer p.stopReplyHeartbeat(rc.chatID, true)\n\tmsgBody := [][]byte{encodeTextBody(content)}\n\tvar frame []byte\n\tif rc.chatType == \"group\" {\n\t\tframe = encodeSendGroupMessage(rc.targetID, msgBody, p.getBotID(), \"\", \"\", \"\")\n\t} else {\n\t\tframe = encodeSendC2CMessage(rc.targetID, msgBody, p.getBotID(), \"\", 0, \"\", \"\")\n\t}\n\tws := p.getWS()\n\tif ws == nil {\n\t\treturn fmt.Errorf(\"yuanbao: not connected\")\n\t}\n\terr := ws.WriteMessage(websocket.BinaryMessage, frame)\n\tif err != nil {\n\t\tslog.Error(\"yuanbao: reply send failed\", \"error\", err)\n\t}\n\treturn err\n}\n\nfunc (p *Platform) Send(ctx context.Context, rctx any, content string) error {\n\treturn p.Reply(ctx, rctx, content)\n}\n\nfunc (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {\n\tparts := strings.SplitN(sessionKey, \":\", 3)\n\tif len(parts) < 2 || parts[0] != \"yuanbao\" {\n\t\treturn nil, fmt.Errorf(\"yuanbao: invalid session key %q\", sessionKey)\n\t}\n\tchatID := parts[1]","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/yuanbao/platform.go#L398-L434","documentation":"Reply obtains the current WebSocket connection via getWS(); if it returns nil the platform has no live connection and this error is returned instead of attempting a write. It means the client is not connected to the yuanbao gateway at send time.","triggerScenarios":"Calling Reply (directly or via ReconstructReplyCtx) before Start finishes connecting, after a disconnect, or during a reconnect window.","commonSituations":"Network outage dropped the WebSocket; server restarted the bot; reply attempt races with shutdown; connection never established due to bad ws_url or auth failure.","solutions":["Check startup logs for the connection/auth failure that left getWS() nil and fix it (ws_url, token, network)","Retry the reply after the platform reconnects; add retry-with-backoff around Reply","Verify the bot process is running and the WebSocket heartbeat keeps the connection alive","Queue outbound messages until the connected state is restored"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if p.getWS() == nil { return errors.New(\"yuanbao not connected; defer send\") }","typeGuard":null,"tryCatchPattern":"err := p.Reply(ctx, rctx, text)\nfor i := 0; err != nil && strings.Contains(err.Error(), \"not connected\") && i < 5; i++ { time.Sleep(time.Second << i); err = p.Reply(ctx, rctx, text) }","preventionTips":["Wait for the platform's connected/ready signal before sending","Keep heartbeat/reconnect logic healthy and monitored","Queue outbound messages during disconnects","Alert on repeated not-connected errors"],"tags":["websocket","connection","yuanbao"],"backgroundTag":"connection-refused","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}