-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: <Heartbeat not working in Android when application in background> #536
Labels
kind/bug
Categorizes issue or PR as related to a bug.
Comments
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
//【1】: When user logined im and im runs works right (in android application)
//【2】: App runs in background or screen lock situation
//【3】: heart beat in android client blocked and sendPingToServer() never involved
`func (c *LongConnMgr) heartbeat(ctx context.Context) {
log.ZDebug(ctx, "heartbeat start", "goroutine ID:", getGoroutineID())
ticker := time.NewTicker(pingPeriod)
defer func() {
ticker.Stop()
log.ZWarn(c.ctx, "heartbeat closed", nil, "heartbeat", "heartbeat done sdk logout.....")
}()
for {
select {
case <-ctx.Done():
log.ZInfo(ctx, "heartbeat done sdk logout.....")
return
case <-c.heartbeatCh:
c.sendPingToServer(ctx)
case <-ticker.C:
c.sendPingToServer(ctx) //██ Blocked Here 🆕🆕🆕
}
}
}`
//【4】Server will never receive ping from client every 30 seconds
//【5】Server will close this connection becouse heart beat failed from client
//【6】Client will receive 10006 error and reconnect to server
//【7】above progress will repeat every 30 seconds
//██ the result is when app in background, the reconnect progress will repeat every 30s. Server will consume lots of resources.
What did you expect to happen?
When client in background, the heartbeat can work right. On the other word, CODE_1 will still work when client in bacground.
`func (c *LongConnMgr) heartbeat(ctx context.Context) {
log.ZDebug(ctx, "heartbeat start", "goroutine ID:", getGoroutineID())
ticker := time.NewTicker(pingPeriod)
defer func() {
ticker.Stop()
log.ZWarn(c.ctx, "heartbeat closed", nil, "heartbeat", "heartbeat done sdk logout.....")
}()
for {
select {
case <-ctx.Done():
log.ZInfo(ctx, "heartbeat done sdk logout.....")
return
case <-c.heartbeatCh:
c.sendPingToServer(ctx)
case <-ticker.C:
c.sendPingToServer(ctx) //██ CODE_1
}
}
}`
How can we reproduce it (as minimally and precisely as possible)?
App runs in background or screen lock situation
Anything else we need to know?
No response
version
Cloud provider
OS version
Install tools
The text was updated successfully, but these errors were encountered: