         # If this is the first time we connect, then we just retry after the
         # initial backoff (there's no need to calculate backoff and so on).
         if info == :init do
-          {:backoff, @initial_backoff, %{state | current_backoff: @initial_backoff}}
+          {:backoff, @backoff_initial, %{state | backoff_current: @backoff_initial}}
         else
-          next_backoff = calc_next_backoff(state.current_backoff, state.opts[:backoff_max])
-          {:backoff, next_backoff, %{state | current_backoff: next_backoff}}
+          next_backoff = calc_next_backoff(state.backoff_current, state.opts[:backoff_max])
+          {:backoff, next_backoff, %{state | backoff_current: next_backoff}}
         end
       other ->
         other


    :ok = SharedState.disconnect_clients_and_stop(state.shared_state)

    state = %{state | socket: nil, current_backoff: @initial_backoff}
    {:backoff, @initial_backoff, state}
  end

  @doc false

    shared_state: nil,
    # The current backoff (used to compute the next backoff when reconnecting
    # with exponential backoff)
    backoff_current: nil,
  ]

  # TODO: right now, if backoff_max is less then 500ms (=
  # @backoff_initial), we do weird stuff.
  @backoff_initial 500

  @backoff_exponent 1.5

