Note that there are some explanatory texts on larger screens.

plurals
  1. POErlang SSL module not functional through Rebar app compared to when run standalone
    primarykey
    data
    text
    <p>I am developing an SSL server application that is supposed to accept connections and respond in a simple fashion. I have created the skeleton of the application in a regular Erlang script which has been tested in the Erlang shell. This approach worked flawlessly, but when trying to implement it in Rebar the module stopped working.</p> <p>My module looks like this (called api):</p> <pre><code>-define(SSL_OPTIONS, [{active, false}, {reuseaddr, true}, {certfile,"../priv/certificate.pem"}, {keyfile,"../priv/key.pem"}]). start() -&gt; try ssl:start(), Pid = listen(3000), {ok, Pid} catch _:_ -&gt; error end. listen(Port) -&gt; {ok, LSocket} = ssl:listen(Port, ?SSL_OPTIONS), spawn(fun() -&gt; accept(LSocket) end). accept(LSocket) -&gt; {ok, Socket} = ssl:transport_accept(LSocket), Pid = spawn(fun() -&gt; communicator:loop(Socket) end), ssl:controlling_process(Socket, Pid), ?MODULE:accept(LSocket). </code></pre> <p>My implementation of the Rebar app looks like follows (called redirector_app):</p> <pre><code>-module(redirector_app). -behaviour(application). %% Application callbacks -export([start/2, stop/1]). %% =================================================================== %% Application callbacks %% =================================================================== start(_StartType, _StartArgs) -&gt; redirector_sup:start_link(), spawn(fun() -&gt; init() end). stop(_State) -&gt; ok. init() -&gt; api:start(), ok. </code></pre> <p>I can start the api module by going into the ebin folder, where the .beam files are located and running the Erlang shell. Within the Erlang shell I run the command:</p> <pre><code>api:start(). </code></pre> <p>However, when I try to run the Rebar app from the same folder and same shell with:</p> <pre><code>redirector_app:start([],[]). </code></pre> <p>I receive the following error:</p> <pre><code>Error in process &lt;0.50.0&gt; with exit value: {{badmatch,{error,einval}},[{ssl,transport_accept,2,[{file,"ssl.erl"},{line,197}]},{api,accept,1,[{file,"src/api.erl"},{line,25}]}]} </code></pre> <p>This doesn't change if I go to the root of the Rebar app and run the Erlang shell with:</p> <pre><code>$ erl -pa ebin/ </code></pre> <p>I have narrowed the problem down to an issue with the connection. I think the connection actually closes before ssl:transport_accept(LSocket) is run. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload