   defp negotiate_protocol(%{socket: socket, opts: opts} = s) do
     case :gen_tcp.recv(socket, 2, opts[:timeout] || @timeout) do
       {:ok, <<version :: short>>} ->
+        check_min_protocol!(version)
         {:ok, %{s | protocol_version: version}}
       {:error, reason} ->
         {:tcp_error, reason}


  @typep state :: Map.t

  @protocol 30

  @timeout 5000

        end
    end
  end

  defp check_min_protocol!(protocol) when protocol < @min_protocol do
    raise Error, """
    the minimum supported protocol is #{@min_protocol}, the server is using #{protocol}
    """
  end

  defp check_min_protocol!(_) do
    :ok
  end
end
