# Decoding message.data in MatchLoop throws exception

**URL:** <https://forum.heroiclabs.com/t/decoding-message-data-in-matchloop-throws-exception/2412>\
**Category:** Runtime Framework\
**Created:** [February 26, 2022, 4:40pm UTC](https://forum.heroiclabs.com/t/decoding-message-data-in-matchloop-throws-exception/2412 "2022-02-26T16:40:37Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [April 14, 2022, 9:07am UTC](https://forum.heroiclabs.com/t/decoding-message-data-in-matchloop-throws-exception/2412/5 "2022-04-14T09:07:34Z")

</div>

Here a results of my research:

1. Transport serialization type (plain json or protobuf) depends on client side. You should use the Protobuf Adapter with Nakama JS SDK [nakama-js/packages/nakama-js-protobuf at master · heroiclabs/nakama-js · GitHub](https://github.com/heroiclabs/nakama-js/tree/master/packages/nakama-js-protobuf) for this.

2. But protobuf serialization works only for nakama build-in data messages. You should serialize your data by yourself ([Protobuf and REST API - #2 by novabyte](https://forum.heroiclabs.com/t/protobuf-and-rest-api/437/2)) because there is no way to extend nakama build-in protobuf schemas ([Decode own protocol protobuf messages in JS client - #2 by mofirouz](https://forum.heroiclabs.com/t/decode-own-protocol-protobuf-messages-in-js-client/2466/2)). Easiest way is msgpack ([MessagePack: It's like JSON. but fast and small.](https://msgpack.org/index.html)), but there is a huge owerhead because msgpack data contains field names

3. JS SDK have issues with sending binary data itself also. Discussion and solution here - [Nakama js client has problems with decoding data](https://forum.heroiclabs.com/t/nakama-js-client-has-problems-with-decoding-data/2467)

4. Typescript server framework have wrong binary array data declarations. Discussion and solution here - [[TS] Fix wrong binary array data declaration · Issue #66 · heroiclabs/nakama-common · GitHub](https://github.com/heroiclabs/nakama-common/issues/66)

3 and 4 will be fixed soon i hope

---

_[View the full topic](https://forum.heroiclabs.com/t/decoding-message-data-in-matchloop-throws-exception/2412)._
