Added a double connection check for the publish