Fixing connection-closed behavior to detect on attempt to publish