TL; DR: is there reusable code to automatically reconnect to a TCP server, which sometimes fails?
I am writing a server application - I call it hal- it also opens some TCP connections with other servers - among them xbmc. I originally wrote this so that when it xbmcfails, the xbmcerlang process will stop and subsequently restart by its supervisor.
This is apparently not a very good way to make persistent TCP connections in erlang. First of all, this really does not work: if it xbmcfails, the processes will restart too quickly, and the supervisor will shut down the entire program hal. Secondly, I apparently shouldn't use a supervisor to do this: Erlang Supervisor's strategy for reloading connections to Downed Hosts (When I read this related question only answers “does the supervisor solve this?”, And is not a duplicate of my question )
I think this sounds like a reasonably common use case, keeping the TCP connection as possible as possible, even with a host that goes blank from time to time. Is there some kind of OTP or other library code that I should use to achieve this?
source
share