• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: javascript: from a websocket I receive messages as zlib deflate: how to read OR “unflate” OR “deflate” (not inflate)

Resolved: javascript: from a websocket I receive messages as zlib deflate: how to read OR “unflate” OR “deflate” (not inflate)

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

This question is about converting a gzip deflate message from a websocket message and convert it to array OR raw text that I can apply JSON.parse on it…
*** to be also clear: In this question : i use a websocket from a crypto exchange…. but the question is about the received message NOT about crypto exchange
in the documentation they say “please use zlib deflate”
HERE THE JAVASCRIPT
I have this in the log
I tried with <script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.0.4/pako.min.js" ...></script> if I do pako.deflate(jsonx); I get
If I add decoder = new TextDecoder("utf8"); and log(decoder.decode(jsonx)); I get
but, HOW TO RETREIVE the array or raw data that I could json.parse ????

Answer:

If I decompress your data twice, I get:
It looks like you compressed instead of decompressed. Use pako.inflate().

If you have better answer, please add a comment about this, thank you!

deflate uint8array uint8t websocket zlib
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Java Virtual Machines deleted

27/03/2023

Resolved: PyCharm cannot see my newly compiled .pyc see on import

27/03/2023

Resolved: I am facing ERR_HTTP2_PROTOCOL_ERROR on my website

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.