openimsdk/open-im-server · error
code %d, msg %s
Error message
code %d, msg %s
What it means
getui (GeTui push service) responses are parsed by parseError, which maps tokenExpireCode to ErrTokenExpire and code 0 to success. Any other code means GeTui rejected the request, and the raw code/msg pair is surfaced as fmt.Errorf("code %d, msg %s", ...). It indicates an upstream push API failure (auth, quota, bad cid, etc.).
Source
Thrown at internal/push/offlinepush/getui/body.go:46
Default: 1,
}
msgCategory = "CATEGORY_MESSAGE"
)
type Resp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data any `json:"data"`
}
func (r *Resp) parseError() (err error) {
switch r.Code {
case tokenExpireCode:
err = ErrTokenExpire
case 0:
err = nil
default:
err = fmt.Errorf("code %d, msg %s", r.Code, r.Msg)
}
return err
}
type RespI interface {
parseError() error
}
type AuthReq struct {
Sign string `json:"sign"`
Timestamp string `json:"timestamp"`
AppKey string `json:"appkey"`
}
type AuthResp struct {
ExpireTime string `json:"expire_time"`
Token string `json:"token"`
}View on GitHub (pinned to 175a7bb067)
Solutions
- Read r.Code and r.Msg in the error; look up the code in GeTui's API docs for the specific cause
- Fix GeTui credentials (appkey/appid/mastersecret) in the push config
- Refresh the device token / stop pushing to stale cids
- Implement backoff if the code indicates rate limiting
Example fix
// before pusher.Push(ctx, badCID, msg) // -> 'code 20002, msg cid invalid' // after token := getValidDeviceToken(userID); pusher.Push(ctx, token, msg)
Defensive patterns
Strategy: try-catch
Validate before calling
// validate credentials and cid before pushing
if pushCfg.Getui.AppKey == "" || pushCfg.Getui.MasterSecret == "" {
return errors.New("getui credentials not configured")
}
if deviceToken == "" { return errors.New("no valid getui cid for user") } Try / catch
if err := resp.parseError(); err != nil {
if errors.Is(err, ErrTokenExpire) {
if rerr := reissueTokenAndRetry(ctx, req); rerr != nil { return rerr }
} else {
log.ZWarn(ctx, "getui push rejected", err) // inspect code/msg for cause
}
} Prevention
- Keep GeTui appkey/appid/mastersecret current in config
- Purge stale device cids from the push table
- Handle token-expire code with automatic re-auth + retry
- Watch GeTui docs for new response codes
When it happens
Trigger: A push request to GeTui returns a Resp whose Code is neither 0 nor the token-expire code — e.g. invalid appkey/secret, expired credentials other than the known expire code, invalid target cid, or rate limiting.
Common situations: Wrong or rotated GeTui app credentials in config; push token (cid) of an uninstalled/invalid device; exceeding GeTui QPS/quota; GeTui API changes introducing new error codes.
Related errors
AI-assisted analysis of openimsdk/open-im-server@175a7bb067 (2026-09-04).
Data as JSON: /api/errors/f5eef5abc51f7b75.
Report an issue: GitHub.