unable to publish long key item in multichain stream

+129 votes
str2 len: 137

error details:
b'{"method":"publish","params":["stream3","789c33343730b2303130b734d1b33436353334325788d650f77556d75150373435f055d7d45100f203817c330330db3118c8064a813911200e84e9eb02d503d1e2e70b97097207c978b81b18181a9ac43bba3b873803b1aebbb3a3bba3638873bc879b7778b84b704444bc0f5009447b00588f6f6251b64b69414e667262496ab1ba662c002ad42742","7b2730277d"],"id":"88675825-1702840795","chain_name":"tchain"}\n\nerror code: -8\nerror message:\nItem key is too long\n'


I am trying to publish a key (in byte form) having size 137 bytes, which is within the limit ( upto 256bytes). But still "long key error" is coming. Before this error, I was able to publish with long key in first try.
asked Dec 17, 2023 by anju

1 Answer

0 votes
Key parameters are passed as plain text, not hexadecimal, so this is indeed longer than the size limit.
answered Dec 18, 2023 by MultiChain 1 flag
I have compressed and converted key value in hex format. Now , key value is 137bytes
  When I tried to compress and converted the byte to string format while publishing, I was able to publish. But faced problem while converting string back to byte form for decoding.
Can you suggest a solution for this problem?
It depends on your programming language. There will be some way to convert between text and hexadecimal. But in general I'm not sure why you're putting so much data in the key - its main purpose is for indexing and retrieval, not the data itself.
Ok, thanks for the reply.