Add check on web socket open, close #2039