Encode connection authorization key once.

This also fixes an uncaught rollback of 1217b4d and sends the length of the bytes object instead of the original string.