fix bug for handshake and protobuf decode