# Connect To nakama server using socket

**URL:** <https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065>\
**Category:** Game Design\
**Created:** [October 20, 2020, 2:52pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065 "2020-10-20T14:52:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArmanBM](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@ArmanBM](https://forum.heroiclabs.com/u/ArmanBM)\
**Post date:** [October 20, 2020, 2:52pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/1 "2020-10-20T14:52:09Z")

</div>

Hello.  
I want to use Nakama as a game server. but the client is codded in AS3 (Air).  
I found no SDK in As3, so it seems I have two options. Rest And Sockets.

how can I connect to Nakama server through socket?  
is it possible without a client SDK?

---

<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:** [October 20, 2020, 10:22pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/2 "2020-10-20T22:22:34Z")

</div>

Hi @ArmanBM welcome 👋

I didn’t know development continued with ActionScript3 (Adobe Air) games. You can connect direct to a socket if you have a WebSocket client which you can use from the Air runtime with a session token. Have a look at this part of the .NET code:

[https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/WebSocketAdapter.cs#L91-L135](https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/WebSocketAdapter.cs#L91-L135)

We don’t do anything proprietary within our client SDKs its all open-source. 🙂

Hope it helps.

---

<div class="post-metadata">

**Author:** ![ArmanBM](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@ArmanBM](https://forum.heroiclabs.com/u/ArmanBM)\
**Post date:** [October 21, 2020, 5:24am UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/3 "2020-10-21T05:24:06Z")

</div>

Tanks, it definitely helps.

what should I pass as “url” in snipped code? is it “127.0.0.1” (root) or somewhere else?  
how can I know the list of available commands? for example authentication through socket?  
or updating player coins?

---

<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:** [October 21, 2020, 1:42pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/4 "2020-10-21T13:42:18Z")

</div>

> what should I pass as “url” in snipped code? is it “127.0.0.1” (root) or somewhere else?

The client is open-source so you can see the URL construction in the code:

[https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/Socket.cs#L497-L508](https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/Socket.cs#L497-L508)

> how can I know the list of available commands?

You can see the realtime protocol defined here:

[https://github.com/heroiclabs/nakama-common/blob/master/rtapi/realtime.proto](https://github.com/heroiclabs/nakama-common/blob/master/rtapi/realtime.proto)

You can also read the [documentation](https://heroiclabs.com/docs/) of the server which covers all the realtime features in detail.

> for example authentication through socket? or updating player coins?

You don’t authenticate over the socket but via the REST/GRPC API. Have a look at the code for how to obtain a session token:

[https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/ApiClient.gen.cs#L3423-L3465](https://github.com/heroiclabs/nakama-dotnet/blob/master/src/Nakama/ApiClient.gen.cs#L3423-L3465)

---

<div class="post-metadata">

**Author:** ![ArmanBM](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@ArmanBM](https://forum.heroiclabs.com/u/ArmanBM)\
**Post date:** [October 25, 2020, 1:33pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/5 "2020-10-25T13:33:46Z")

</div>

Thanks for the complete reply.  
Flash Rest API does not support Authentication in the header!  
Is there any other way for me to use authentication using AS3?

---

<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:** [October 26, 2020, 12:37pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/6 "2020-10-26T12:37:42Z")

</div>

> Is there any other way for me to use authentication using AS3?

Sadly, no. There’s no other way to authenticate with the game server because we rely on using standard HTTP headers for both `"Bearer"` and `"Basic"` auth as a way to authenticate and authorize the request.

---

<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:** [October 26, 2020, 12:39pm UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/7 "2020-10-26T12:39:49Z")

</div>

Is there a reason you still develop games with AS3? Could you not move to a newer engine or toolchain?

---

<div class="post-metadata">

**Author:** ![yooni126](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/yooni126/32/467_2.png) [@yooni126](https://forum.heroiclabs.com/u/yooni126)\
**Post date:** [January 18, 2021, 9:15am UTC](https://forum.heroiclabs.com/t/connect-to-nakama-server-using-socket/1065/8 "2021-01-18T09:15:53Z")

</div>

it supports it, I already have an adobe air(AS3) project and I’m using the Bearer token in the header!  
also if you have a flash project you can use Smartfox Server ,
