Socket hangup issue with appium using iOS

Im observing an Error socket hang up issue with Econnreset.
My custom app initially uses the network its connected with and fetches some data from the server and displays. Now after accessing some objects on different screen then again I need to change my network. Means initially app connected with router1 and middle of the test need to connect to router2 .
So in this case we access IPAD wifi settings to connect with router2. After this we need to go back to our custom app/ So we re-launch app using activate_app and when we relaunch the custom app, socket hang up is observed.

appium 1.17.1.
MAC OS : catalina 10.5
iPAD ver : 13.5.1
Real Device

def activate_iPad_WiFiSettings(self):
try:
print(“activate_iPad_WiFiSettings”)
logging.info(“activate_iPad_WiFiSettings”)
time.sleep(1)
self.desired_caps[“bundleId”] = ‘com.apple.Preferences’
self.driver.execute_script(‘mobile: activateApp’, self.desired_caps);
time.sleep(1)
except WebDriverException:
time.sleep(0.5)
self.kill_ipad_wifi_settings()
Below function called after the execution of the above one. Then i see the issue
def activate_sms_app(self):
try:
retry_cnt=0
time.sleep(1)
print(“activate_custom app”)
logging.info(“Activate custom App”)
self.desired_caps[“bundleId”] = self.data[‘app_details’][‘bundleId’]
self.driver.execute_script(‘mobile: activateApp’, self.desired_caps);
time.sleep(1)
except WebDriverException:
self.sms_kill_ios_app()