Check that socket object exists before calling subscribe