Added connect and error events