# Match handler match\_leave is called with a long delay

**URL:** <https://forum.heroiclabs.com/t/match-handler-match-leave-is-called-with-a-long-delay/2752>\
**Category:** Runtime Framework\
**Tags:** lua\
**Created:** [June 19, 2022, 8:08pm UTC](https://forum.heroiclabs.com/t/match-handler-match-leave-is-called-with-a-long-delay/2752 "2022-06-19T20:08:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amuuu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/amuuu/32/1048_2.png) [@amuuu](https://forum.heroiclabs.com/u/amuuu)\
**Post date:** [June 19, 2022, 8:08pm UTC](https://forum.heroiclabs.com/t/match-handler-match-leave-is-called-with-a-long-delay/2752/1 "2022-06-19T20:08:33Z")

</div>

Hello,

I’ve been testing the game we’ve been developing on real mobile builds. I have noticed that when the game is suddenly closed, match handler’s `match_leave` is called instantly, but when I only turn off the wifi and LTE of the running instance, it takes a long time for the `match_leave` to be called. Maybe that has something to do with the background processes of Android?

We experimented with the `ping_period_ms` and `pong_wait_ms` values in the config. They did help a little bit. But they have a threshold. When their values is too small, the clients get in the constant loop of disconnecting and connecting again.

It’s critical for our match handler to notice leaves and joins as soon as possible because it directly affects the gameplay. Are there ways for us to improve this?

Thank you!

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [June 20, 2022, 11:06am UTC](https://forum.heroiclabs.com/t/match-handler-match-leave-is-called-with-a-long-delay/2752/2 "2022-06-20T11:06:10Z")

</div>

Tuning the `ping_period_ms` and `pong_wait_ms` is the right way to achieve earlier disconnect detection. If you’re using the Unity SDK, you should also configure the `PingPongManager` configuration values accordingly to the server’s values to prevent this reconnection behaviour.
