# \#sdk-javascript

**URL:** https://forum.heroiclabs.com/tag/sdk-javascript/14.md

[Latest](https://forum.heroiclabs.com/latest.md) · [Categories](https://forum.heroiclabs.com/categories.md) · [Tags](https://forum.heroiclabs.com/tags.md)

---

## [Nakama-js throws uncatcheable exception](https://forum.heroiclabs.com/t/nakama-js-throws-uncatcheable-exception/5397)

<div class="topic-metadata">

**Author:** [@thegoldenmule](https://forum.heroiclabs.com/u/thegoldenmule)\
**Replies:** 2\
**Last updated:** [July 4, 2024, 12:57pm UTC](https://forum.heroiclabs.com/t/nakama-js-throws-uncatcheable-exception/5397 "2024-07-04T12:57:12Z")

</div>

I made a PR for this, but the README says I should also post here. Here’s the issue: We are seeing errors in production where this code in socket.ts: this.adapter.onError = (evt) =\> { reject(evt); this.…

---

## [Decoding issue with AES 128 in web browser](https://forum.heroiclabs.com/t/decoding-issue-with-aes-128-in-web-browser/4993)

<div class="topic-metadata">

**Author:** [@rokky](https://forum.heroiclabs.com/u/rokky)\
**Replies:** 0\
**Last updated:** [February 24, 2024, 8:43pm UTC](https://forum.heroiclabs.com/t/decoding-issue-with-aes-128-in-web-browser/4993 "2024-02-24T20:43:28Z")

</div>

Hello, I’m developing a web game using nakama-js. I’m looking to add a feature that requests account information from the server through the client (browser). The server encrypts the account information using AES-128 wit…

---

## [Socket connect giving error 'WebSocket is not defined'](https://forum.heroiclabs.com/t/socket-connect-giving-error-websocket-is-not-defined/4862)

<div class="topic-metadata">

**Author:** [@HailMaverick](https://forum.heroiclabs.com/u/HailMaverick)\
**Replies:** 3\
**Last updated:** [January 12, 2024, 3:37pm UTC](https://forum.heroiclabs.com/t/socket-connect-giving-error-websocket-is-not-defined/4862 "2024-01-12T15:37:33Z")

</div>

Hi, I am trying to build my Bot logic in Javascript using nakama-js. While trying to connect socket to my Nakama server, i am getting error as ‘WebSocket is not defined’. await nSocket.connect(nSession, appearOnline);…

---

## [socket.onDisconnect not working correctly on desktop devices](https://forum.heroiclabs.com/t/socket-ondisconnect-not-working-correctly-on-desktop-devices/3551)

<div class="topic-metadata">

**Author:** [@RobinM](https://forum.heroiclabs.com/u/RobinM)\
**Replies:** 22\
**Last updated:** [November 27, 2023, 2:32pm UTC](https://forum.heroiclabs.com/t/socket-ondisconnect-not-working-correctly-on-desktop-devices/3551 "2023-11-27T14:32:11Z")

</div>

We’re experiencing an issue with the “socket.onDisconnect” callback of the Nakama Javascript SDK. We expect this callback to be executed when the connection to the server is lost, this is working as expected on mobile de…

---

## [Authentication errors not received on client (Only 400 BAD REQUEST)](https://forum.heroiclabs.com/t/authentication-errors-not-received-on-client-only-400-bad-request/2944)

<div class="topic-metadata">

**Author:** [@Rojoss](https://forum.heroiclabs.com/u/Rojoss)\
**Replies:** 7\
**Last updated:** [October 10, 2023, 2:46am UTC](https://forum.heroiclabs.com/t/authentication-errors-not-received-on-client-only-400-bad-request/2944 "2023-10-10T02:46:41Z")

</div>

Is there any way to be able to see the error message for authentication errors? They are not logged on the server runtime and the client does not receive them. The only thing the client receives is a 400 BAD REQUEST. F…

---

## [Nakama JS Client Request Timeout](https://forum.heroiclabs.com/t/nakama-js-client-request-timeout/4342)

<div class="topic-metadata">

**Author:** [@BernardoSantos](https://forum.heroiclabs.com/u/BernardoSantos)\
**Replies:** 4\
**Last updated:** [September 15, 2023, 2:04pm UTC](https://forum.heroiclabs.com/t/nakama-js-client-request-timeout/4342 "2023-09-15T14:04:29Z")

</div>

Hey, var client = new Client( 'my serverkey', 'my serverhost;, 7351 ); Tried both 7351 and 7350 for the port both not working, the host is the same (can easily access the console on same host), server key is als…

---

## [Whats the status on @heroiclabs/nakama-js-protobuf?](https://forum.heroiclabs.com/t/whats-the-status-on-heroiclabs-nakama-js-protobuf/4320)

<div class="topic-metadata">

**Author:** [@elementalcode](https://forum.heroiclabs.com/u/elementalcode)\
**Replies:** 0\
**Last updated:** [September 11, 2023, 12:37am UTC](https://forum.heroiclabs.com/t/whats-the-status-on-heroiclabs-nakama-js-protobuf/4320 "2023-09-11T00:37:02Z")

</div>

What is the current status for @heroiclabs/nakama-js-protobuf? Is it still needed if you want to use protobufs? Currently it’s broken because the isOpen method only exists in the cjs build while the esm build is old. I…

---

## [Nakama-js-protobuf WebSocket adapter not working](https://forum.heroiclabs.com/t/nakama-js-protobuf-websocket-adapter-not-working/3727)

<div class="topic-metadata">

**Author:** [@dragonlobster](https://forum.heroiclabs.com/u/dragonlobster)\
**Replies:** 7\
**Last updated:** [April 4, 2023, 4:37pm UTC](https://forum.heroiclabs.com/t/nakama-js-protobuf-websocket-adapter-not-working/3727 "2023-04-04T16:37:46Z")

</div>

When I receive broadcasted messages from Nakama to the JavaScript Client SDK, I get this which is a protobuf: { match\_id: '5160bac8-bd5d-4319-a9e9-4075bd5f1ecc.nakama', op\_code: 1, data: Uint8Array(1239) \[ 123…

---

## [Integration Testing with JS Client](https://forum.heroiclabs.com/t/integration-testing-with-js-client/3660)

<div class="topic-metadata">

**Author:** [@dragonlobster](https://forum.heroiclabs.com/u/dragonlobster)\
**Replies:** 3\
**Last updated:** [March 20, 2023, 11:40am UTC](https://forum.heroiclabs.com/t/integration-testing-with-js-client/3660 "2023-03-20T11:40:09Z")

</div>

I want to do some integration tests by creating a test node client (without browser) by using javascript client nakama-js and testing authentication, testing RPC calls, websocket etc. However when I tried to run client.a…

---

## [Data object is not a JSON object](https://forum.heroiclabs.com/t/data-object-is-not-a-json-object/3055)

<div class="topic-metadata">

**Author:** [@scott4dev](https://forum.heroiclabs.com/u/scott4dev)\
**Replies:** 2\
**Last updated:** [September 16, 2022, 3:54pm UTC](https://forum.heroiclabs.com/t/data-object-is-not-a-json-object/3055 "2022-09-16T15:54:28Z")

</div>

As PoC I’m trying to write a tic-tac-toe client with React. For the server I’m using nakama-project-template as is, not changes Player 1: is your svelte/phaserjs client and the data property of the OnMatchData messages…

---

## [Message format issues in Tic-Tac-Toe Phaser-Nakama tutorial](https://forum.heroiclabs.com/t/message-format-issues-in-tic-tac-toe-phaser-nakama-tutorial/3031)

<div class="topic-metadata">

**Author:** [@raghu-ma](https://forum.heroiclabs.com/u/raghu-ma)\
**Replies:** 1\
**Last updated:** [September 12, 2022, 9:03am UTC](https://forum.heroiclabs.com/t/message-format-issues-in-tic-tac-toe-phaser-nakama-tutorial/3031 "2022-09-12T09:03:37Z")

</div>

I’m following the setup described in the Tic-Tac-Toe PhaserJS Tutorial The setup described there didn’t work right away. Some additional serializing/deserializing had to be done on the client side. If this understanding…

---

## [Version 2.4.0 published on NPM registry missing nakama-js.cjs.js file](https://forum.heroiclabs.com/t/version-2-4-0-published-on-npm-registry-missing-nakama-js-cjs-js-file/2709)

<div class="topic-metadata">

**Author:** [@MWFIAE](https://forum.heroiclabs.com/u/MWFIAE)\
**Replies:** 1\
**Last updated:** [June 6, 2022, 1:26pm UTC](https://forum.heroiclabs.com/t/version-2-4-0-published-on-npm-registry-missing-nakama-js-cjs-js-file/2709 "2022-06-06T13:26:39Z")

</div>

This post is a copy from the following issue: After upgrading to 2.4.0 I started receiving an error that the nakama-js package could not be resolved because it was missing one of the build files. error While trying to…

---

## [Decode own protocol protobuf messages in JS client](https://forum.heroiclabs.com/t/decode-own-protocol-protobuf-messages-in-js-client/2466)

<div class="topic-metadata">

**Author:** [@Marcin](https://forum.heroiclabs.com/u/Marcin)\
**Replies:** 2\
**Last updated:** [March 23, 2022, 1:18pm UTC](https://forum.heroiclabs.com/t/decode-own-protocol-protobuf-messages-in-js-client/2466 "2022-03-23T13:18:28Z")

</div>

Hi guys, We are using nakama-js with nakama-js-protobuf adapter because our protocol operate on protobuf. I have a question how to integrate our .proto files with websocket protobuf adapter. I see how to update nakama .…

---

## [JS Runtime environment not showing up](https://forum.heroiclabs.com/t/js-runtime-environment-not-showing-up/1622)

<div class="topic-metadata">

**Author:** [@SnappierSoap318](https://forum.heroiclabs.com/u/SnappierSoap318)\
**Replies:** 6\
**Last updated:** [December 29, 2021, 3:06pm UTC](https://forum.heroiclabs.com/t/js-runtime-environment-not-showing-up/1622 "2021-12-29T15:06:04Z")

</div>

I have made a simple js runtime using the typescript example and add the path to docker-compose file and restarted the container, but it doesnt show up in the console, under configuration-\> runtime.js\_entrypoint

---

## [Websocket stability with JS client](https://forum.heroiclabs.com/t/websocket-stability-with-js-client/1992)

<div class="topic-metadata">

**Author:** [@ahmad.wshah](https://forum.heroiclabs.com/u/ahmad.wshah)\
**Replies:** 1\
**Last updated:** [October 5, 2021, 10:22pm UTC](https://forum.heroiclabs.com/t/websocket-stability-with-js-client/1992 "2021-10-05T22:22:12Z")

</div>

Hi, I’m using Nakama to make authoritative match that handled from back end (GO) and for Front End we are using JavaScript Client library. All is good but we have an issue with connection stability with the server when…

---

## [How can I use Nakama with Cocos?](https://forum.heroiclabs.com/t/how-can-i-use-nakama-with-cocos/1912)

<div class="topic-metadata">

**Author:** [@RowdyWabbid](https://forum.heroiclabs.com/u/RowdyWabbid)\
**Replies:** 7\
**Last updated:** [September 2, 2021, 4:29pm UTC](https://forum.heroiclabs.com/t/how-can-i-use-nakama-with-cocos/1912 "2021-09-02T16:29:01Z")

</div>

Hello, Trying to figure out how to use Nakama with cocos creator 3.3. I’m following the guide: JavaScript - Heroic Labs Documentation. When I preview in cocos, this error comes up. \[preview-error\]unhandledrejection: (…

---

## [Can the Nakama server be used to host my web game's UI?](https://forum.heroiclabs.com/t/can-the-nakama-server-be-used-to-host-my-web-games-ui/1730)

<div class="topic-metadata">

**Author:** [@nakamatester1](https://forum.heroiclabs.com/u/nakamatester1)\
**Replies:** 1\
**Last updated:** [June 27, 2021, 1:59pm UTC](https://forum.heroiclabs.com/t/can-the-nakama-server-be-used-to-host-my-web-games-ui/1730 "2021-06-27T13:59:12Z")

</div>

Simple beginner question. Do I need to have a separate server serving a webapp UI which then uses the JS client to talk to a nakama server, or can nakama itself serve the interface? As far as I understand from the docs n…

---

## [Sharing my open source turn-based game made with Nakama and TypeScript](https://forum.heroiclabs.com/t/sharing-my-open-source-turn-based-game-made-with-nakama-and-typescript/1720)

<div class="topic-metadata">

**Author:** [@pi-kei](https://forum.heroiclabs.com/u/pi-kei)\
**Replies:** 3\
**Last updated:** [June 25, 2021, 6:36am UTC](https://forum.heroiclabs.com/t/sharing-my-open-source-turn-based-game-made-with-nakama-and-typescript/1720 "2021-06-25T06:36:22Z")

</div>

I made a game that uses Nakama with both client and server on JavaScript/TypeScript. It has kind of turn-based multiplayer model. The purpose of the game is to make funny poems in collab with other players. The projec…

---

## [Is there support for refresh tokens in Nakama-js?](https://forum.heroiclabs.com/t/is-there-support-for-refresh-tokens-in-nakama-js/1689)

<div class="topic-metadata">

**Author:** [@hybridlink](https://forum.heroiclabs.com/u/hybridlink)\
**Replies:** 5\
**Last updated:** [June 8, 2021, 2:52am UTC](https://forum.heroiclabs.com/t/is-there-support-for-refresh-tokens-in-nakama-js/1689 "2021-06-08T02:52:11Z")

</div>

Hi, Have some problems with using nakama js client, what should I’d when the token will expired soon? client.authenticateEmail return session didn’t bring refresh\_token like account/authenticate/device api, if it will …

---

## [Nakama Js Client With Cocos Creator 3.0](https://forum.heroiclabs.com/t/nakama-js-client-with-cocos-creator-3-0/1266)

<div class="topic-metadata">

**Author:** [@MrZak-dev](https://forum.heroiclabs.com/u/MrZak-dev)\
**Replies:** 6\
**Last updated:** [February 11, 2021, 1:39pm UTC](https://forum.heroiclabs.com/t/nakama-js-client-with-cocos-creator-3-0/1266 "2021-02-11T13:39:33Z")

</div>

Cocos Creator 3.0preview1 removed support for Javascript as a scripting language , instead they are now supporting Typescript as the only scripting language used in The Engine editor . How can i adapt and use the nakama…

---

## [Conditional realtime messages](https://forum.heroiclabs.com/t/conditional-realtime-messages/1302)

<div class="topic-metadata">

**Author:** [@Leonidas](https://forum.heroiclabs.com/u/Leonidas)\
**Replies:** 4\
**Last updated:** [January 21, 2021, 2:43pm UTC](https://forum.heroiclabs.com/t/conditional-realtime-messages/1302 "2021-01-21T14:43:32Z")

</div>

Hi, We are evaluating Nakama for a realtime web game, we are very pleased with the API and the performance (even more pleased with v3.0 and JS/TS support!). One question we have is how can we add conditions to messages…
