Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect network failure #51

Open
quixoten opened this issue Apr 29, 2017 · 0 comments
Open

Detect network failure #51

quixoten opened this issue Apr 29, 2017 · 0 comments

Comments

@quixoten
Copy link
Contributor

I think it would be nice to have a quick way to detect when the network connection disappears unexpectedly. I'm thinking some kind of inactivity timeout that is renewed every time we receive data from the server. When the inactivity timeout is exceeded, a ping should be sent. If the ping times out the GenServer should be stopped.

Not sure how best to implement. Could it be another process that has something like:

# some other module ?
def activity_monitor
  receive do
    :refresh -> activity_monitor
    after 5_000 -> Gnat.ping_or_stop_async(state.gnat)
  end
end

# Gnat module
def handle_info({:tcp, socket, data}, %{socket: socket, parser: parser}=state) do
  ...
  ActivityMonitor.call(state.activity_monitor, :refresh)
  ...
end

I know that is not a fully fleshed out idea, but I think it's enough to understand how I'm thinking about implementing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants