Ensure connection before publishing