I am looking for a way to decompress a websocket response so that I can read it. I have tried zlib, but I am getting Data Errors:
#<Zlib::DataError: incorrect header check> #<Zlib::DataError: unknown compression method>
Here is what I have:
require 'websocket-client-simple'
require 'zlib'
WSURL = 'wss://real.okcoin.com:10440/websocket/okcoinapi'
def inflate(deflated_string)
inflater = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
inflater.inflate(deflated_string)
end
ws = WebSocket::Client::Simple.connect WSURL
ws.on :message do |msg|
puts inflate(msg.data)
end
ws.on :open do
puts "connection opened"
ws.send "{'event':'addChannel','channel':'ok_btcusd_ticker','binary':'true'}"
puts "addChannel sent"
end
ws.on :close do |e|
p e
exit 1
end
ws.on :error do |e|
p e
end
loop do
sleep 1
end
I do not exactly know what it could be?