# How to enable AMF3 metadata and send AMFDataByteArray() to streamSendirect()? NegativeArraySizeException

**URL:** <https://community.wowza.com/t/how-to-enable-amf3-metadata-and-send-amfdatabytearray-to-streamsendirect-negativearraysizeexception/94704>\
**Category:** Wowza Streaming Engine\
**Created:** [March 16, 2022, 9:54pm UTC](https://community.wowza.com/t/how-to-enable-amf3-metadata-and-send-amfdatabytearray-to-streamsendirect-negativearraysizeexception/94704 "2022-03-16T21:54:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Farrow](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@Dan\_Farrow](https://community.wowza.com/u/Dan_Farrow)\
**Post date:** [March 16, 2022, 9:54pm UTC](https://community.wowza.com/t/how-to-enable-amf3-metadata-and-send-amfdatabytearray-to-streamsendirect-negativearraysizeexception/94704/1 "2022-03-16T21:54:08Z")

</div>

Hi, I am trying to inject a byte array as AMF data into my stream, I get this message:

```
AMFDataByteArray.deserialize[15400:4] : java.lang.NegativeArraySizeException|at com.wowza.wms.amf.AMFDataByteArray.deserialize(AMFDataByteArray.java:175)|at com.wowza.wms.amf.AMFDataByteArray.<init>(AMFDataByteArray.java:83)|a

```

I use this to create the AMFDataByteArray and I know the dataBytes array is 15400 bytes:

```
AMFDataContextDeserialize amf3Context = new AMFDataContextDeserialize();
amf3Context.setObjectEncoding(AMFDataObj.AMF_LEVEL3);
AMFDataByteArray amfByteData = new AMFDataByteArray(ByteBuffer.wrap(dataBytes), amf3Context);

```

I am not sure what to do here.

. Also which function do I used to inject this into the stream?

`stream.sendDirect("onDataFunction", amfData);`

or

`stream.sendDirectAMF3("onDataFunction", amfData);`

??

---

<div class="post-metadata">

**Author:** ![Dan\_Farrow](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@Dan\_Farrow](https://community.wowza.com/u/Dan_Farrow)\
**Post date:** [March 28, 2022, 1:07pm UTC](https://community.wowza.com/t/how-to-enable-amf3-metadata-and-send-amfdatabytearray-to-streamsendirect-negativearraysizeexception/94704/2 "2022-03-28T13:07:14Z")

</div>

I figued it out in the HttpProvider I do:

AMFDataObj amfData = new AMFDataObj();  
AMFDataByteArray amfByteData = AMFDataByteArray.wrap(dataBytes);  
amfData.put(“payload”, amfByteData);  
stream.sendDirectAMF3(“onRaceFinisher”, amfData);

and in the module:

---

<div class="post-metadata">

**Author:** ![Connessione](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Connessione](https://community.wowza.com/u/Connessione)\
**Post date:** [March 28, 2022, 4:13pm UTC](https://community.wowza.com/t/how-to-enable-amf3-metadata-and-send-amfdatabytearray-to-streamsendirect-negativearraysizeexception/94704/3 "2022-03-28T16:13:43Z")

</div>

Sometimes your are the best help for yourself 🙂. Thanks for sharing this information.

---

<div class="post-metadata">

**Author:** ![Dan\_Farrow](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@Dan\_Farrow](https://community.wowza.com/u/Dan_Farrow)\
**Post date:** [March 29, 2022, 3:29pm UTC](https://community.wowza.com/t/how-to-enable-amf3-metadata-and-send-amfdatabytearray-to-streamsendirect-negativearraysizeexception/94704/4 "2022-03-29T15:29:42Z")

</div>

Woops, my post got truncated, just to specify:

I figured it out in the HttpProvider I do:

```
AMFDataObj amfData = new AMFDataObj();
AMFDataByteArray amfByteData = AMFDataByteArray.wrap(dataBytes);
amfData.put(“payload”, amfByteData);
stream.sendDirectAMF3(“onRaceFinisher”, amfData);

```

and in the module, in **onFillChunkDataPacket** :

```
AMFDataObj dataObj = amfList.getObject(1);
AMFData amfData = dataObj.get("payload");
AMFDataByteArray amfDataBytes = (AMFDataByteArray)amfData;
byte[] dataPayload = amdDataBytes.toArray();
```
