# Disconnect an existing client connection when a second login is detected

**URL:** <https://forum.heroiclabs.com/t/disconnect-an-existing-client-connection-when-a-second-login-is-detected/50>\
**Category:** Local Setup\
**Created:** [July 4, 2019, 10:06am UTC](https://forum.heroiclabs.com/t/disconnect-an-existing-client-connection-when-a-second-login-is-detected/50 "2019-07-04T10:06:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mofirouz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mofirouz/32/1523_2.png) [@mofirouz](https://forum.heroiclabs.com/u/mofirouz)\
**Post date:** [July 4, 2019, 10:34am UTC](https://forum.heroiclabs.com/t/disconnect-an-existing-client-connection-when-a-second-login-is-detected/50/2 "2019-07-04T10:34:56Z")

</div>

There is no way for the server to queue things and wait for them before disconnecting the socket as various operations of the server runs concurrently.

One alternative is to introduce a delay between sending notification and closing the socket on the Runtime code. This should help ensure message delivery to the client.

Also I suggest taking a look at this forum post:

> [@Preventing users from having multiple sessions](https://forum.heroiclabs.com/t/preventing-users-from-having-multiple-sessions/36/6):
>
> Thanks @hdjay0129. That’s a great answer. I’ll add more detail for @naskha01 and anyone who stumbles across this question. When a socket connection is opened with a session to Nakama the session is implicitly placed onto the notification stream. This allows the user to receive [in-app notifications](https://heroiclabs.com/docs/social-in-app-notifications/) to that session. With the low level [streams feature](https://heroiclabs.com/docs/advanced-streams/) in Nakama you can take advantage of this info to check whether a session for the user already exists with a [stream count](https://heroiclabs.com/docs/advanced-streams/#counting-stream-presences) of that notification stream…

---

_[View the full topic](https://forum.heroiclabs.com/t/disconnect-an-existing-client-connection-when-a-second-login-is-detected/50)._
