Splits out the reusable parts of connect_ws, then exposes them for H2
connections as well. This only works because websockets and H2 share
their "transport route" (a TLS connection of some kind) and can thus
store their connection history in the same kind of attempts record.