# HG changeset patch # User Emmanuel Gil Peyrot # Date 1310822966 -7200 # Node ID d63a2784564dc1a81046ad0a68cd28a721b13895 # Parent 9e21bd93f79dd3ec33455e39ab01178af87be8fb Set a timeout for the vCard stanza. diff --git a/avatar.js b/avatar.js --- a/avatar.js +++ b/avatar.js @@ -117,7 +117,7 @@ if (config.useGravatar) method: 'GET' }; - util.log('No XMPP avatar, falling back to Gravatar for ' + to + '.'); + util.log('No XMPP avatar or timeout, falling back to Gravatar for ' + to + '.'); var r = http.request(options, function(r) { if (r.statusCode != 200) @@ -245,6 +245,7 @@ var getVCard = function(jid, res) { .up(); conn.send(toSend); + setTimeout(noAvatar, config.timeout, res, jid, 'Error: XMPP timeout.'); sent[id] = res; } diff --git a/configuration.js.example b/configuration.js.example --- a/configuration.js.example +++ b/configuration.js.example @@ -38,14 +38,14 @@ config.webPort = 8032; // Directory for the cache of the images. config.directory = 'data'; -// When true, assume that the TYPE of the avatar is image/png if not -// specified. Warning: it doesn’t follow the spec and is only a -// workaround for buggy clients. -config.guessType = false; - // Time after which the avatar will be retrieved again, in seconds. config.expire = 24*60*60; +// Time to wait for a response to a stanza, in milliseconds. This is +// needed for inexistent domain because with some XMPP servers, the +// default is to wait one minute. +config.timeout = 1000; + // Allowed extensions, associated with their MIME type. config.extensions = { png: 'image/png', @@ -58,8 +58,13 @@ config.extensions = { // a SVG image will be displayed. //config.defaultImage = 'http://example.org/default.svg'; +// When true, assume that the TYPE of the avatar is image/png if not +// specified. Warning: it doesn’t follow the spec and is only a +// workaround for buggy clients. +config.guessType = false; + // Try Gravatar if there is a problem during XMPP avatar retrieving. -//config.useGravatar = false; +config.useGravatar = false; // Prints XMPP stanzas config.debug = false;