Note that there are some explanatory texts on larger screens.

plurals
  1. PODisconnect node-xmpp client
    text
    copied!<p>I am looking at <a href="https://github.com/astro/node-xmpp" rel="nofollow">node-xmpp</a> and <a href="https://github.com/arunoda/node-simple-xmpp" rel="nofollow">node-simple-xmpp</a> and I am trying to make a simple client.<br> Everything works fine, except the disconnect. </p> <p>I have made the following file after the <a href="https://github.com/arunoda/node-simple-xmpp/blob/master/examples/echo.js" rel="nofollow">example</a> of simple-xmpp:</p> <pre><code>var xmpp = require('simple-xmpp'); xmpp.on('online', function() { console.log('Yes, I\'m connected!'); xmpp.send('test2@example.com', 'Hello test'); // OK UNTIL HERE, DISCONNECT NOW }); xmpp.connect({jid: 'test@example.com/webchat', password: 'test', reconnect: 'false'}); </code></pre> <p>But I don't know how to disconnect. I tried to send a stanza with unavailable type:</p> <pre><code>stanza = new xmpp.Element('presence', {from: 'test@example.com', type: 'unavailable'}); xmpp.conn.send(stanza); delete xmpp; </code></pre> <p>This is causing the client to go temporarily offline, but the problem is, it reconnects after a few seconds and keeps sending 'presence' stanza.</p> <p>I have also tried calling xmpp.conn.end(), which also disconnects but it gives an error afterwards:</p> <pre><code>node_modules/simple-xmpp/node_modules/node-xmpp/lib/xmpp/connection.js:100 if (!this.socket.writable) { ^ TypeError: Cannot read property 'writable' of undefined </code></pre> <p>So, what am I doing wrong? I am sure there is an easy way to disconnect.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload