diff options
Diffstat (limited to 'xmpp-vala/src/core/stream_connect.vala')
-rw-r--r-- | xmpp-vala/src/core/stream_connect.vala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/xmpp-vala/src/core/stream_connect.vala b/xmpp-vala/src/core/stream_connect.vala index a4c5b82e..17d47f38 100644 --- a/xmpp-vala/src/core/stream_connect.vala +++ b/xmpp-vala/src/core/stream_connect.vala @@ -69,8 +69,16 @@ namespace Xmpp { stream.add_module(module); } + uint connection_timeout_id = Timeout.add_seconds(30, () => { + warning("Connection attempt timed out"); + stream.disconnect(); + return Source.REMOVE; + }); + yield stream.connect(); + Source.remove(connection_timeout_id); + return new XmppStreamResult() { stream=stream }; } catch (IOError e) { warning("Could not establish XMPP session with %s:%i: %s", target.host, target.port, e.message); |