websockex icon indicating copy to clipboard operation
websockex copied to clipboard

example echo_client not working

Open farmio opened this issue 7 years ago • 1 comments

When running echo_client example in iex I get an error: %WebSockex.ConnError{original: :closed} from start_link()

It works fine if I replace wss:// with ws://

def start_link(opts \\ []) do
    WebSockex.start_link("ws://echo.websocket.org/?encoding=text", __MODULE__, :fake_state, opts)
  end

farmio avatar Jan 20 '19 10:01 farmio

change the (above) example code to the following to make it work:

def start_link(opts \\ []) do
    WebSockex.start_link("wss://echo.websocket.org/?encoding=text", __MODULE__, :fake_state,
      ssl_options: [
        ciphers: :ssl.cipher_suites() ++ [{:rsa, :aes_128_cbc, :sha}]
      ]
    )
end

In recent versions of the erlang OTP distribution they dropped old/unsafe cipher suites from the default list. You can add specific ciphers back as shown in the above code, it adds the cipher that's (currently) used by the echo.websocket.org webserver.

(I found this specific cipher by iterating over all ciphers :ssl.cipher_suites(:all) and evaluate if the connection can be made, in the case of the echo.websocket.org webserver it only supports the {:rsa, :aes_128_cbc, :sha} cipher currently. They could change this at any time by upgrading/changing their webserver configuration by the way)

redmar avatar Apr 17 '19 20:04 redmar