Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 72533164eca40ab9d5382f0828309d88f5bfe9ff 1 parent 7fdaeb6
@ferd ferd authored
View
4 src/socketio_transport_htmlfile.erl
@@ -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 =
View
4 src/socketio_transport_polling.erl
@@ -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 =
View
6 src/socketio_transport_websocket.erl
@@ -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 }),
View
32 src/socketio_transport_xhr_multipart.erl
@@ -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 }),
Please sign in to comment.
Something went wrong with that request. Please try again.