:ssl.connect failing with badarg for protocol: :dtls

Hi there

:ssl.connect("localhost", 9999, [protocol: :dtls])

is crashing with badarg

iex(2)> :ssl.start
iex(3)> :ssl.connect("localhost", 9999, [protocol: :dtls])
** (exit) exited in: :gen_statem.call(#PID<0.125.0>, {:start, :infinity}, :infinity)
    ** (EXIT) :badarg
    (stdlib) gen.erl:177: :gen.do_call/4
    (stdlib) gen_statem.erl:619: :gen_statem.call_dirty/4
    (ssl) ssl_connection.erl:2490: :ssl_connection.call/2
    (ssl) ssl_connection.erl:123: :ssl_connection.handshake/2
    (ssl) dtls_connection.erl:76: :dtls_connection.start_fsm/8
    (ssl) ssl_connection.erl:92: :ssl_connection.connect/8
    (ssl) ssl.erl:536: :ssl.connect/4

Erlang and SSL Versions:

iex(3)> :ssl.versions
  ssl_app: '9.2',
  supported: [:"tlsv1.2"],
  supported_dtls: [:"dtlsv1.2"],
  available: [:"tlsv1.3", :"tlsv1.2", :"tlsv1.1", :tlsv1, :sslv3],
  available_dtls: [:"dtlsv1.2", :dtlsv1]
iex(4)>  :erlang.system_info(:otp_release)

I don’t get this error when running this in the erlang shell for the same erlang version, i waits for infinity for the handshake to begin.

ssl:connect("localhost", 9999, [{protocol, dtls}])

Seems to be reproduceable by just running the connect command as I did above

I’m running Elixir on Windows.

Anyone else get this error?

The :badarg is complaining about "localhost", which is a binary. :ssl.connect/3 is expecting a charlist though. Please use singlequotes or the sigil_c.


AAAH Wrecked by charlist once again!!!

I’m kicking myself right now! XD

Thank you SO MUCH @NobbZ !!!

This is the first thing to doublecheck whenever you are dealing directly with erlang modules.

Though more and more of the erlang distributed applications and their functions are changing to accept both.

1 Like