I started Inets http with:
> inets:start(httpd, [{port, 8060}, {server_name, "myserver"},
> {server_root, "/Users/jonas/code"},
> {document_root, "/Users/jonas/code/mydocs"},
> {bind_address, {192, 168, 2, 5}}]).
{error,inets_not_started}
so the only error information I have is {error,inets_not_started}
. Is there any way I can get more information on what went wrong?
First, to solve your problem just start inets application (error reason indicates it is not started) by:
inets:start().
Second, in general starting SASL application improves a bit readability of Erlang/OTP errors/crashes - but it is not the case here.
You need to call inets:start/0
first. See the inets documentation for more details.
start(Service, ServiceConfig, How) -> {ok, Pid} | {error, Reason}
Dynamically starts an inets service after the inets application has been started.
So you need call this function first.
start() -> start(Type) -> ok | {error, Reason}
Types: Type = permanent | transient | temporary
Starts the Inets application.
This is a great question because of the unfortunate overloading of the inets:start/[0,1,2,3]
function and the httpc
documentation isn't very clear that starting inets
will automatically start the httpc
service as well.
Especially when on simply jumps to the HTTP CLIENT SERVICE START/STOP section to get started quickly, thus missing the note in the module description .
inets:start/[0,1]
starts the inets
application itself and the httpc
service with the default profile called default
(this is only documented in httpc
).
inets:start/[2,3]
(which should be called start_service
) starts one of the services that can run atop inets
(viz. ftpc
, tftp
, httpc
, httpd
) once the inets
application has already started .
start() ->
start(Type) -> ok | {error, Reason}
Starts the Inets application.
start(Service, ServiceConfig) -> {ok, Pid} | {error, Reason}
start(Service, ServiceConfig, How) -> {ok, Pid} | {error, Reason}
Dynamically starts an Inets service after the Inets application has been started
(withinets:start/[0,1]
).
httpc
From the top of the httpc
module documentation :
When starting the Inets application, a manager process for the default profile is started. The functions in this API that do not explicitly use a profile accesses the default profile.
That is, the httpc
service will automatically get started using the default profile called default
.
1> inets:start().
ok
2> httpc:get_options(all, default).
{ok,[{proxy,{undefined,[]}},
{https_proxy,{undefined,[]}},
{pipeline_timeout,0},
{max_pipeline_length,2},
{max_keep_alive_length,5},
{keep_alive_timeout,120000},
{max_sessions,2},
{cookies,disabled},
{verbose,false},
{ipfamily,inet},
{ip,default},
{port,default},
{socket_opts,[]},
{unix_socket,undefined}]}
3>
3> inets:start(httpc, [{profile, lofa}]).
{ok,<0.95.0>}
4>
5> httpc:get_options(all, default).
{ok,[...]}
6> httpc:get_options(all, lofa).
{ok,[...]}
Interestingly, when using a non-existing profile, the error message is inets_not_started
:
7> httpc:get_options(all, balabab).
{error,inets_not_started}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.