Fixed for sending events before socket is connected