[Solved] exception error: bad argument in function [closed]


Presumably this happens because Token and Payload are binaries, not integers.

When constructing a binary like this, everything is assumed to be a 1-byte integer unless specified otherwise. To insert Token and Payload into the binary being constructed, use the /binary suffix:

Packet =[<<0:8, TokenLength, Token/binary, PayloadLength, Payload/binary>>],

solved exception error: bad argument in function [closed]