Fixed to emit a real Error object. Added connect and disconnect messages.