laforge has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo_dia2gsup/+/34199 )
Change subject: gsup: Attempt reconnecting if connect fails ......................................................................
gsup: Attempt reconnecting if connect fails
Related: OS#5657 Change-Id: I47b6db0f0267bbd4c80fbac9d51a8647862827a0 --- M src/gsup_client.erl 1 file changed, 25 insertions(+), 12 deletions(-)
Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve pespin: Verified
diff --git a/src/gsup_client.erl b/src/gsup_client.erl index 50a9bf6..047078b 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 might 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,