Permalink
Browse files

Warning messages on configuration loading failure

The current behaviour of the application when the configuration value
for heartbeats (and a delay for closing files in xhr) was to silently
ignore the issue and substitute it by a default value.

This patch adds warning messages going through the standard error_logger
in order to let the user of socket.io-erlang know something went wrong.

The default heartbeat value from websockets was also changed from
infinity to 10 seconds, the same as in the app file we currently have.
Setting it to infinity had as a consequence that the client code would
always disconnect from the protocol, without closing the websocket. This
would result in a particular tab of a browser holding dozens of live
websockets that can receive data (and look alive to the server) but not
send any from all of them but the last one.
  • Loading branch information...
ferd committed Jun 2, 2011
1 parent 7fdaeb6 commit 72533164eca40ab9d5382f0828309d88f5bfe9ff
@@ -61,6 +61,10 @@ init([Sup, SessionId, ServerModule, {'htmlfile', {Req, Caller}}]) ->
{ok, Time} ->
Time;
_ ->
+ error_logger:warning_report(
+ "Could not load default heartbeat_interval value from "
+ "the application file. Setting the default value to infinity."
+ ),
infinity
end,
CloseTimeout =
@@ -61,6 +61,10 @@ init([Sup, SessionId, ServerModule, {TransportType, {Req, Index}}]) ->
{ok, Time} ->
Time;
_ ->
+ error_logger:warning_report(
+ "Could not load default heartbeat_interval value from "
+ "the application file. Setting the default value to 20000 ms."
+ ),
20000
end,
CloseTimeout =
@@ -57,7 +57,11 @@ init([Sup, SessionId, ServerModule, ConnectionReference]) ->
{ok, Time} ->
Time;
_ ->
- infinity
+ error_logger:warning_report(
+ "Could not load default heartbeat_interval value from "
+ "the application file. Setting the default value to 10000 ms."
+ ),
+ 10000
end,
{ok, EventMgr} = gen_event:start_link(),
socketio_client:send(self(), #msg{ content = SessionId }),
@@ -57,19 +57,27 @@ init([Sup, SessionId, ServerModule, {'xhr-multipart', {Req, Caller}}]) ->
apply(ServerModule, ensure_longpolling_request, [Req]),
process_flag(trap_exit, true),
HeartbeatInterval =
- case application:get_env(heartbeat_interval) of
- {ok, Time} ->
- Time;
- _ ->
- infinity
- end,
+ case application:get_env(heartbeat_interval) of
+ {ok, Time} ->
+ Time;
+ _ ->
+ error_logger:warning_report(
+ "Could not load default heartbeat_interval value from "
+ "the application file. Setting the default value to infinity."
+ ),
+ infinity
+ end,
CloseTimeout =
- case application:get_env(close_timeout) of
- {ok, Time0} ->
- Time0;
- _ ->
- 8000
- end,
+ case application:get_env(close_timeout) of
+ {ok, Time0} ->
+ Time0;
+ _ ->
+ error_logger:warning_report(
+ "Could not load default close_timeout value from "
+ "the application file. Setting the default value to 8000 ms."
+ ),
+ 8000
+ end,
{ok, EventMgr} = gen_event:start_link(),
gen_server:cast(self(), {initialize, Req}),
socketio_client:send(self(), #msg{ content = SessionId }),

0 comments on commit 7253316

Please sign in to comment.