Skip to content

Can't run example code in v1.6.0 #186

@chelyabinsk

Description

@chelyabinsk

Hi

This might be a "read the f-ing manual" problem, so apologies in advance. I'm using Julia 1.8.2 and I tried running the below code

using WebSockets
import JSON


const url = "wss://ws.kraken.com/"

WebSockets.open(url) do ws_client  
    # msg = "{\"event\":\"subscribe\", \"subscription\":{\"name\":\"trade\"}, \"pair\":[\"XBT/USD\",\"XRP/USD\"]}"

    msg = Dict(
        "event" => "subscribe", 
        "subscription" => Dict("name" => "trade"),
        "pair" => ["XBT/USDT", "XBT/USD"]
    )
    msg = JSON.json(msg)

    writeguarded(ws_client, msg)

    while (true)
        data, success = readguarded(ws_client)
        if success
            println(stderr, ws_client, " received:", String(data))
        end
            
    end
end;

When I use v1.5.9 it works fine, but with v1.6.0 I get no output.

I also tried this code

using WebSockets, JSON

uri = "wss://www.bitmex.com/realtime"

payload = Dict(
               :op => "subscribe",
               :args => "trade:XBT"
           )

function open_websocket() 
   WebSockets.open(uri) do ws
     if isopen(ws)
      try
       write(ws, JSON.json(payload))
      catch e
        println(e)
      end
     end

     while isopen(ws)
       data, success = readguarded(ws)
       if success
         data = JSON.parse(String(data))
         print(data, "\n")
       end
     end

     if !isopen(ws)
       @async open_websocket()
     end

   end
 end
       
open_websocket()

Which works in v1.5.9 but in v.1.6.0 I get the following error

ErrorException("OpenSSL.SSLStream does not support byte I/O")

I noticed that when I downgrade down to v1.5.9 HTTP library is also downgraded quite significantly. Here is the log after I run add [email protected]

(@v1.8) pkg> add [email protected]
   Resolving package versions...
    Updating `~/.julia/environments/v1.8/Project.toml`
⌅ [cd3eb016] ↓ HTTP v1.9.6 ⇒ v0.9.17
⌃ [104b5d7c] ↓ WebSockets v1.6.0 ⇒ v1.5.9
    Updating `~/.julia/environments/v1.8/Manifest.toml`
  [d1d4a3ce] - BitFlags v0.1.7
  [944b1d66] - CodecZlib v0.7.1
  [f0e56b4a] - ConcurrentUtilities v2.2.0
⌅ [cd3eb016] ↓ HTTP v1.9.6 ⇒ v0.9.17
  [83e8ac13] + IniFile v0.5.1
  [e6f89c97] - LoggingExtras v1.0.0
  [4d8831e6] - OpenSSL v1.4.1
  [777ac1f9] - SimpleBufferStream v1.1.0
  [3bb67fe8] - TranscodingStreams v0.9.13
⌃ [104b5d7c] ↓ WebSockets v1.6.0 ⇒ v1.5.9

I'm happy to continue using v1.5.9, but I wonder if anyone else had the same issue. Feel free to ask any clarifying questions :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions