Philipp Hörist pushed to branch master at gajim / gajim


Commits:
61fa2bb0 by Philipp Hörist at 2026-08-04T21:22:06+02:00
fix: Client: Rework connectivity check

Use new nbxmpp methods to check connectivity

Fixes #12690

- - - - -


1 changed file:

- gajim/common/client.py


Changes:

=====================================
gajim/common/client.py
=====================================
@@ -231,51 +231,17 @@ def _network_status_changed(
         self, monitor: Gio.NetworkMonitor, _network_available: bool
     ) -> None:
 
-        if monitor.get_connectivity() == Gio.NetworkConnectivity.FULL:
+        connectivity = monitor.get_connectivity()
+        if connectivity == Gio.NetworkConnectivity.FULL:
             return
 
-        reachable = self.remote_is_reachable()
-        self._log.info("Network status changed, reachable: %s", reachable)
+        self._log.info("Network status changed, %r", connectivity)
 
-        if reachable:
+        if self._client is None:
             return
 
         if self._state.is_connected or self._state.is_available:
-            self.disconnect(gracefully=False, reconnect=True)
-
-    def remote_is_reachable(self) -> bool:
-        if self._client is None:
-            return True
-
-        address = self._client.remote_address
-        if address is None:
-            # Address is None when websocket is used
-            self._log.info(
-                "Unable to determine if host is reachable, remote address 
unknown"
-            )
-            return True
-
-        monitor = Gio.NetworkMonitor.get_default()
-        try:
-            address, port = address.rsplit(":", maxsplit=1)
-            return monitor.can_reach(
-                Gio.InetSocketAddress.new_from_string(address, int(port))
-            )
-        except GLib.Error as error:
-            quark = GLib.quark_try_string("g-io-error-quark")
-            if error.matches(quark, Gio.IOErrorEnum.HOST_UNREACHABLE):
-                return False
-
-            log.exception(
-                "Unable to determine if %r is reachable", 
self._client.remote_address
-            )
-            return True
-
-        except Exception:
-            log.exception(
-                "Unable to determine if %r is reachable", 
self._client.remote_address
-            )
-            return True
+            self._client.check_if_connected()
 
     def disconnect(
         self, gracefully: bool, reconnect: bool, destroy_client: bool = False



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/61fa2bb04bd5b284f3194c82cdae3898fae842bb

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/61fa2bb04bd5b284f3194c82cdae3898fae842bb
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to