Skip to content
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

Open
Vihanmy opened this issue Mar 23, 2024 · 2 comments
Open
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@Vihanmy
Copy link

Vihanmy commented Mar 23, 2024

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

```console $ {name} 3.4.1 # paste output here ```

Cloud provider

//【】

OS version

```console # On Linux: $ cat /etc/os-release # paste output here $ uname -a # paste output here # On Windows: C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture # paste output here ```

Install tools

@Vihanmy Vihanmy added the bug Categorizes issue or PR as related to a bug. label Mar 23, 2024
@kubbot kubbot changed the title Bug: <Heart beat not working in Android when applicaiton in backgroung> Bug: <Heartbeat not working in Android when application in background> Mar 23, 2024
@kubbot
Copy link
Contributor

kubbot commented May 23, 2024

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.

@kubbot kubbot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 23, 2024
@kubbot
Copy link
Contributor

kubbot commented May 30, 2024

This issue was closed because it has been stalled for 7 days with no activity.

@kubbot kubbot closed this as completed May 30, 2024
@FGadvancer FGadvancer reopened this Jul 5, 2024
@kubbot kubbot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants