     end
   end
 
-  defp calc_next_backoff(current_backoff, backoff_max) do
-    next_exponential_backoff = round(current_backoff * @backoff_exponent)
+  defp calc_next_backoff(backoff_current, backoff_max) do
+    next_exponential_backoff = round(backoff_current * @backoff_exponent)
 
     if backoff_max == :infinity do
       next_exponential_backoff

        # 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}}
        else
          next_backoff = calc_next_backoff(state.current_backoff, state.opts[:backoff_max])
          {:backoff, next_backoff, %{state | current_backoff: next_backoff}}
        end
      other ->
        other


    :ok = SharedState.disconnect_clients_and_stop(state.shared_state)

    state = %{state | socket: nil, backoff_current: @backoff_initial}
    {:backoff, @backoff_initial, state}
  end

  @doc false
