I want to use the library GitHub - qzhuyan/quicer which is written in Erlang.
The readme contains a sample snippet:
application:ensure_all_started(quicer),
Port = 4567,
LOptions = [ {certfile, "cert.pem"}
, {keyfile, "key.pem"}
, {alpn, ["sample"]}
, {peer_bidi_stream_count, 1}
],
{ok, L} = quicer:listen(Port, LOptions),
{ok, Conn} = quicer:accept(L, [], 120000),
{ok, Conn} = quicer:handshake(Conn),
{ok, Stm} = quicer:accept_stream(Conn, []),
receive {quic, <<"ping">>, Stm, _Props} -> ok end,
{ok, 4} = quicer:send(Stm, <<"pong">>),
quicer:close_listener(L).
which I translated to the following:
:application.ensure_all_started(:quicer)
port = 4567
l_options = [
{:certfile, "cert.pem"},
{:keyfile, "key.pem"},
{:alpn, ["sample"]},
{:peer_bidi_stream_count, 1}
]
# {:error, :badarg}
{:ok, listener} = :quicer.listen(port, l_options)
{:ok, conn} = :quicer.accept(listener, [], 120_000)
{:ok, conn} = :quicer.handshake(conn)
{:ok, stm} = :quicer.accept_stream(conn, [])
receive do
{:quic, <<"ping">>, stm, _props} -> :ok
end
{:ok, 4} = :quicer.send(stm, <<"pong">>)
:quicer.close_listener(listener)
Something seems to be wrong, as there is a badarg (marked above).
ElixirLS Dialyzer is reporting the following:
The call quicer:listen
(_port@1 :: 4567,
_l_options@1 ::
[{'alpn', [<<_:48>>, ...]} |
{'certfile', <<_:64>>} |
{'keyfile', <<_:56>>} |
{'peer_bidi_stream_count', 1},
...]) breaks the contract
(listen_on(), listen_opts()) ->
{'ok', listener_handler()} |
{'error', 'listener_open_error', atom_reason()} |
{'error', 'listener_start_error', atom_reason()}
What am I missing?
PS: ChatGPT came to the same translation