also added the subprotocol fix here. but this branch is actually useless because the tls branch can do both plain and secure connections