pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/erlang/osmo_dia2gsup/+/34199 )


Change subject: gsup: Attempt reconnecting if connec fails
......................................................................

gsup: Attempt reconnecting if connec fails

Change-Id: I47b6db0f0267bbd4c80fbac9d51a8647862827a0
---
M src/gsup_client.erl
1 file changed, 24 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/erlang/osmo_dia2gsup 
refs/changes/99/34199/1

diff --git a/src/gsup_client.erl b/src/gsup_client.erl
index 204dd76..55b1c5d 100644
--- a/src/gsup_client.erl
+++ b/src/gsup_client.erl
@@ -65,17 +65,20 @@
        ipa_proto:init(),
        % register the GSUP codec with the IPA core; ignore result as we mgiht 
be doing this multiple times
        ipa_proto:register_codec(?IPAC_PROTO_EXT_GSUP, fun 
gsup_protocol:encode/1, fun gsup_protocol:decode/1),
+       connect([Address, Port, Options]).
+
+connect([Address, Port, Options]) ->
        lager:info("Connecting to GSUP HLR on IP ~s port ~p~n", [Address, 
Port]),
-        CcmOptions = #ipa_ccm_options{
-                serial_number="HSS-00-00-00-00-00-00",
-                unit_id="0/0/0",
-                mac_address="00:00:00:00:00:00",
-                location="00:00:00:00:00:00",
-                unit_type="00:00:00:00:00:00",
-                equipment_version="00:00:00:00:00:00",
-                sw_version="00:00:00:00:00:00",
-                unit_name="HSS-00-00-00-00-00-00"
-                },
+       CcmOptions = #ipa_ccm_options{
+               serial_number="HSS-00-00-00-00-00-00",
+               unit_id="0/0/0",
+               mac_address="00:00:00:00:00:00",
+               location="00:00:00:00:00:00",
+               unit_type="00:00:00:00:00:00",
+               equipment_version="00:00:00:00:00:00",
+               sw_version="00:00:00:00:00:00",
+               unit_name="HSS-00-00-00-00-00-00"
+               },
        case ipa_proto:connect(Address, Port, Options) of
                {ok, {Socket, IpaPid}} ->
                        ipa_proto:set_ccm_options(Socket, CcmOptions),
@@ -85,11 +88,11 @@
                        {ok, #gsupc_state{socket=Socket, ipa_pid=IpaPid}};
                {error, Reason} ->
                        lager:error("Connecting to GSUP HLR on IP ~s port ~p 
failed: ~p~n", [Address, Port, Reason]),
+                       lager:info("Reconnecting to GSUP HLR in 5s...~n", []),
                        timer:sleep(5000),
-                       {stop, Reason}
+                       connect([Address, Port, Options])
        end.

-
 % send a given GSUP message and synchronously wait for message type ExpRes or 
ExpErr
 handle_call({transceive_gsup, GsupMsgTx, ExpRes, ExpErr}, _From, State) ->
        Socket = State#gsupc_state.socket,

--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo_dia2gsup/+/34199
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: erlang/osmo_dia2gsup
Gerrit-Branch: master
Gerrit-Change-Id: I47b6db0f0267bbd4c80fbac9d51a8647862827a0
Gerrit-Change-Number: 34199
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to