     {:noreply, %{state | sock: nil, state: nil}, @connect_retry}
   end
 
+  def handle_info(:timeout, %{sock: nil}) do
+    Logger.debug "Connecting to instrumental"
+    case connect() do
+      {:ok, sock} ->
+        Logger.debug "Instrumental connected"
+        {:noreply, %State{sock: sock}, 0}
+      _error ->
+        {:noreply, %State{}, @connect_retry}
+    end
+  end
   def handle_info(:timeout, %{sock: sock, state: nil} = state) do
     case :gen_tcp.send(sock, Protocol.hello) do
       :ok ->

#

defmodule Instrumental.Connection do
  alias Instrumental.Protocol
  alias Instrumental.Config



  def init([]) do
    if Config.enabled? do
      {:ok, %State{}, 0}
    else
      :ignore
    end
