More robust handling of proxy connections and disconnections