# Socket.RpcAsync vs. Client.RpcAsync

**URL:** <https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831>\
**Category:** Game Design\
**Tags:** server-framework\
**Created:** [June 25, 2020, 5:29am UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831 "2020-06-25T05:29:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![codedrunk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/codedrunk/32/95_2.png) [@codedrunk](https://forum.heroiclabs.com/u/codedrunk)\
**Post date:** [June 25, 2020, 5:29am UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/1 "2020-06-25T05:29:17Z")

</div>

I’m using Nakama in .Net/Unity application to build a mobile application.

My question is: **do `Nakama.Socket.RpcAsync` and `Nakama.Client.RpcAsync` have the same functionality? Which one is recommended to use?**

I’m a game developer so I don’t know much about networks. I see that `Client.RpcAsync` uses `HttpAdapter` while `Socket.RpcAsync` uses `SocketAdapter`. I read that socket takes more time to establish connection compared to http, but once the connection is established, it uses less network traffic than http, and is much faster. I also read that in OSI model, http starts on the 7th layer while socket starts from the 5th layer. Which should mean that socket is much faster.

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [June 30, 2020, 4:23am UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/2 "2020-06-30T04:23:28Z")

</div>

@codedrunk The choice between `socket.RpcAsync` and `client.RpcAsync` is not really about speed. It’s true that once the socket is established messages can be sent and received without the overhead of SSL negotiation on each request but SSL negotiation on HTTP requests is also how most of the internet works day to day so the overhead isn’t great relative to practical usage.

The choice between which to use depends on whether your game already requires a socket to be active for other features like chat, multiplayer, in-app notifications, etc. My suggestion is to start with `client.RpcAsync` always and consider using `socket.RpcAsync` when the game design will naturally take advantage of the socket for other features.

Also don’t forget to consider that an active socket connection requires heartbeats between client-\>server and server-\>client which is done automatically. This improves the time to detect the in-active socket (half-closed) but incurs a small amount of battery drain on mobile. This is true of any socket-based network connectivity.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![mengxin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mengxin/32/1879_2.png) [@mengxin](https://forum.heroiclabs.com/u/mengxin)\
**Post date:** [April 18, 2024, 10:40am UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/3 "2024-04-18T10:40:59Z")

</div>

Does using socket RPC increase the server load? I mean, if the socket is already being used by other real-time features and we also use the socket for RPC, does it increase the server load compared to the client RPC?

---

<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:** [April 18, 2024, 2:44pm UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/4 "2024-04-18T14:44:07Z")

</div>

No, it should be the opposite, as @novabyte mentions this would prevent the overhead of SSL negotiation, but given that it’s such a common operation these days it’s very heavily optimized, so the difference shouldn’t be meaningful.

---

<div class="post-metadata">

**Author:** ![mengxin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mengxin/32/1879_2.png) [@mengxin](https://forum.heroiclabs.com/u/mengxin)\
**Post date:** [May 15, 2024, 2:21pm UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/5 "2024-05-15T14:21:32Z")

</div>

May i aks one more question about the Socket RpcAsync. does the socket RPC can help guarantee the RPC reach server is ordered?

such as Send RpcA with d1 at T1 and then Send RpcA with d2 at T2, then could we expect the sever to receive the data d1 and then receive data d2 always?

---

<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:** [May 15, 2024, 3:44pm UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/6 "2024-05-15T15:44:07Z")

</div>

@mengxin yes, the RPC invoked within the same socket are processed in-order.

---

<div class="post-metadata">

**Author:** ![mengxin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mengxin/32/1879_2.png) [@mengxin](https://forum.heroiclabs.com/u/mengxin)\
**Post date:** [May 15, 2024, 3:55pm UTC](https://forum.heroiclabs.com/t/socket-rpcasync-vs-client-rpcasync/831/7 "2024-05-15T15:55:01Z")

</div>

> [@sesposito](#):
>
> the RPC invoked within the same socket are processed in-order.

Thanks for your quick reply!
