xmppjs / xmpp.js Goto Github PK
View Code? Open in Web Editor NEWXMPP for JavaScript
License: ISC License
XMPP for JavaScript
License: ISC License
Hi,
I've prosody installed, but I was wondering if is possible to proxy it with node-xmpp (S2S maybe?)
What I want to do:
I know that I could implement prosody plugins, but I'd to know if I can has a "fake" xmpp server with node-xmpp that routes everthing to a real xmpp server (then I could implement my modules/plugins in node).
if it is possible, can you give me a very simple code sample?
/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:145
this.socket.setSecure(credentials || this.credentials);
^
TypeError: Object # has no method 'setSecure'
at Client.setSecure (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:145:17)
at Client.onStanza (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:167:14)
at StreamParser. (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:96:14)
at StreamParser.emit (events.js:42:17)
at [object Object]. (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/stream_parser.js:38:22)
at StreamParser.write (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/stream_parser.js:64:26)
at Client.onData (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:139:21)
at Socket. (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:29:14)
at Socket.emit (events.js:59:20)
at Socket._onReadable (net.js:649:14)
I have node+node-xmpp+dependencies setup in my Linux and mac box. While I am able to do a successful run of c2s.js with degus_c2s.js in Linux, I am getting the following error stack trace on server (c2s) side in MAC:
events.js:101
this.domain.exit();
^
TypeError: Object localhost has no method 'exit'
at C2SStream.EventEmitter.emit (events.js:101:19)
at StreamParser.Connection.startParser (/Users/kartikrustagi/Research/node/node-xmpp/projectx/lib/xmpp/connection.js:138:14)
at StreamParser.EventEmitter.emit (events.js:88:17)
at null. (/Users/kartikrustagi/Research/node/node-xmpp/projectx/lib/xmpp/stream_parser.js:19:18)
at EventEmitter.emit (events.js:91:17)
at Parser.parse (/Users/kartikrustagi/Research/node/node-xmpp/projectx/node_modules/node-expat/lib/node-expat.js:18:22)
at StreamParser.write (/Users/kartikrustagi/Research/node/node-xmpp/projectx/lib/xmpp/stream_parser.js:80:26)
at C2SStream.Connection.onData (/Users/kartikrustagi/Research/node/node-xmpp/projectx/lib/xmpp/connection.js:192:21)
at Socket.Connection.setupStream.proxyEvent (/Users/kartikrustagi/Research/node/node-xmpp/projectx/lib/xmpp/connection.js:54:14)
at Socket.EventEmitter.emit (events.js:115:20)
I am just not able to figure out the cause for this. I can see that the last thing the server sent were the features:
{ name: 'stream:features',
parent: null,
attrs: {},
children:
[ { name: 'mechanisms',
parent: [Circular],
attrs: [Object],
children: [Object] } ] }
and the thing the client sent was:
{ name: 'auth',
parent: null,
attrs:
{ xmlns: 'urn:ietf:params:xml:ns:xmpp-sasl',
mechanism: 'PLAIN' },
children: [ 'anVsaWVuQGxvY2FsaG9zdABqdWxpZW4AcGFzc3dvcmQ=' ] }
Please help.
There seems to be a bug in bosh.js line #156.
You are calling request with parameters for this.request. Even if you call this.request it would still be a wrong since this.request increments this.rid (which shouldn't happen in case of retry).
i don't think facebook authentication stuff belongs into this package, because it is a xmpp library for node.js not for facebook.
facebook !== xmpp
and i am not only opening this bug because i dont like facebook …
ain't working with node 0.4 :(
Buddycloud throws below exception that seems to be caused by node-xmpp (using Debian packaging of latest releases: node-xmpp 0.3.2 node-expat 1.5.0, ltx 0.2.0):
/usr/lib/nodejs/node-xmpp/xmpp/stream_parser.js:15 this.parser.addListener('startElement', function(name, attrs) { ^ TypeError: Object [object Object] has no method 'addListener' at new StreamParser (/usr/lib/nodejs/node-xmpp/xmpp/stream_parser.js:15:17) at Component.startParser (/usr/lib/nodejs/node-xmpp/xmpp/connection.js:118:19) at EventEmitter. (/usr/lib/nodejs/node-xmpp/xmpp/component.js:40:11) at EventEmitter.emit (events.js:64:17) at Socket. (/usr/lib/nodejs/node-xmpp/xmpp/srv.js:95:18) at Socket.emit (events.js:64:17) at Object.afterConnect [as oncomplete] (net.js:652:10)
hi,
I just got the latest node-xmpp from npm but it seems to be broken :(
when requiring it, I get the following error:
/opt/nodejs/v0.1.103/lib/node/.npm/node-xmpp/active/package/lib/xmpp/xml.js:144
v = v.toString();
^
TypeError: Cannot call method 'toString' of undefined
at Element.write (/opt/nodejs/v0.1.103/lib/node/.npm/node-xmpp/active/package/lib/xmpp/xml.js:144:12)
at Element.toString (/opt/nodejs/v0.1.103/lib/node/.npm/node-xmpp/active/package/lib/xmpp/xml.js:129:10)
at Element.STRING_ADD_RIGHT (native)
at Object.puts (sys:13:12)
thanks!
danielz
Here is a bunch of missing features and suggestions to add to the C2S implementation :
this.emit('stanza', stanza, this);
from the C2SStream's onRawStanza method for clarity.[I will add more as I'm working on more xmpp-server stuff to be implemented!]
send(stanza, sentCallback)
Requires custom buffer mgmt, never pause during a stanza
You need to add the automatic reconnection in case of error or close the stream.
Add option: xmpp.Client({ reconnect: true });
I've version 0.2.2 of node-xmpp installed
I'd like to report a problem with node-xmpp related to messages containing links.
I have an "old" application written on node which sends some messages on a jabber chatroom.
It was written quite some time ago.
When I send a message containing a link using node.xmpp
I don't know if this has been solved in the meantime, I haven't checked the latest node-xmpp.
Anyway, here's a testcase
//c here is a xmpp-client object
var m =
new xmpp.Element('message',{to: "some_chatroom@some_domain",type: 'groupchat'})
.c('body')
.c('p');
//m
//.c('p')
//.t("test");
m
.c('a',{href: "http://www.github.com"})
.t("html link test");
c.xmpp.send(m);
Hi,
thanks for your great work but I had a problem on my Mac with Snow Leopard. If I tried to connect to a jabber server like draugr.de or jabme.de I get followed error:
/Users/Christoph/node_modules/node-xmpp/lib/starttls.js:27
var verifyError = pair._ssl.verifyError();
^
TypeError: Cannot call method 'verifyError' of undefined
at SecurePair.<anonymous> (/Users/Christoph/node_modules/node-xmpp/lib/starttls.js:27:33)
at SecurePair.emit (events.js:61:17)
at SecurePair.maybeInitFinished (tls.js:598:10)
at CleartextStream._push (tls.js:269:17)
at SecurePair.cycle (tls.js:574:20)
at EncryptedStream.write (tls.js:96:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:678:14)
at IOWatcher.onReadable [as callback] (net.js:177:10)
I installed version 0.2.6 of node-xmpp over npm.
Thanks
Christoph
Are there plans to add convenient IQ request/reply support? If not, would you be willing to tak a pull request?
Dear Astro,
I was looking at node-xmpp as a possible option to implement an xmpp-client for our application. But since this is a commercial application we cannot release the code as open source given the GPL license. Is there any other license that is also applicable (for example, some projects offer the possibility to choose between an MIT license and GPL)?
I completely understand the advantages of GPL, its just that we cannot use it for a program that may be released as closed source at some point in the future.
A quick clarification would help me and perhaps other folks looking to build commercial applications using your library.
Cheers!
Sachin
hi,
I installed node-xmpp using npm, but when I try to use it I get errors when autoloading dependent modules: node-expat and base64
to fix it I replaced:
xmpp/connection.js line: 3
var expat = require('expat');
to var expat = require('node-expat');
there is another problem with base64 import, but it seems to be a problem with that package itself, so I'll report it to the package maintainer.
thx, regards
danielz
hi, it would be great if you could add an event when data is sent out. this would make debugging easier.
I checked out the code and if you added this line:
this.emit('send', stanza);
to connection.js, line 41 it would make it.
(I still need to figure out how to use git :/ to send patches)
i get some error with installing node-xmpp (node version 0.7.8):
markus:Desktop markus$ npm install node-xmpp
npm http GET https://registry.npmjs.org/node-xmpp
npm http 304 https://registry.npmjs.org/node-xmpp
npm http GET https://registry.npmjs.org/node-expat
npm http GET https://registry.npmjs.org/ltx
npm http 304 https://registry.npmjs.org/node-expat
npm http 304 https://registry.npmjs.org/ltx
[email protected] install /Users/markus/node_modules/node-xmpp/node_modules/node-expat
node-waf configure build
npm http GET https://registry.npmjs.org/sax
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
Checking for header expat.h : not installed
/Users/markus/node_modules/node-xmpp/node_modules/node-expat/wscript:13: error: the configuration failed (see '/Users/markus/node_modules/node-xmpp/node_modules/node-expat/build/config.log')
npm ERR! [email protected] install: node-waf configure build
npm ERR! sh "-c" "node-waf configure build"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls node-expat
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/usr/bin/npm" "install" "node-xmpp"
npm ERR! cwd /Users/markus/Desktop
npm ERR! node -v v0.7.8
npm ERR! npm -v 1.1.18
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: node-waf configure build
npm ERR! message sh "-c" "node-waf configure build"
failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/markus/Desktop/npm-debug.log
npm not ok
markus:Desktop markus$
I was consistently able to reproduce the following stack error (read : this happens quite often) :
net.js:391
throw new Error('Socket is not writable');
^
Error: Socket is not writable
at Socket._writeOut (net.js:391:11)
at Socket.<anonymous> (net.js:377:17)
at Socket.write (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/idle_timeout.js:22:18)
at /home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:87:25
at /home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:82:21
at Element.write (/home/node/msgboy-xmpp-server/node_modules/ltx/lib/element.js:189:13)
at /home/node/msgboy-xmpp-server/node_modules/ltx/lib/element.js:198:23
at Array.forEach (native)
at Element.write (/home/node/msgboy-xmpp-server/node_modules/ltx/lib/element.js:196:23)
at Socket.serializeStanza (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:81:20)
at [object Object].send (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:86:21)
at [object Object].error (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:295:10)
at DomainContext.addInStream (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/router.js:200:19)
at [object Object].<anonymous> (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/router.js:330:18)
at [object Object].emit (events.js:72:17)
at [object Object].<anonymous> (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/server.js:48:22)
at [object Object].emit (events.js:81:20)
at [object Object].onStanza (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:215:14)
at StreamParser.<anonymous> (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:116:14)
at StreamParser.emit (events.js:64:17)
at [object Object].<anonymous> (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/stream_parser.js:42:22)
at [object Object].emit (events.js:64:17)
at [object Object].emit (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/node_modules/node-expat/lib/node-expat.js:14:12)
at [object Object].parse (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/node_modules/node-expat/lib/node-expat.js:20:24)
at StreamParser.write (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/stream_parser.js:78:26)
at [object Object].onData (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:164:21)
at Socket.<anonymous> (/home/node/msgboy-xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:50:14)
at Socket.emit (events.js:81:20)
at Socket._onReadable (net.js:678:14)
at IOWatcher.onReadable [as callback] (net.js:177:10)
Based on my understanding, it happens when S2S connections are replaced by another one. Not sure how to handle this gracefuly.
npm installing this on Mac OS X fails on calling browserify.
See npm output below:
npm http 304 https://registry.npmjs.org/wordwrap
> [email protected] postinstall /Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp
> browserify -d -o node-xmpp-browser.js lib/node-xmpp-browserify.js
Expressions in require() statements:
require(modName)
Expressions in require() statements:
require(requestPath)
Expressions in require() statements:
require(wsPath)
Expressions in require() statements:
require(stringprepPath)
require(stringprepPath)
Expressions in require() statements:
require(dnsPath)
/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/lib/wrap.js:444
throw moduleError('Cannot find module');
^
Error: Cannot find module: "JID" from directory "/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/lib" while processing file /Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/lib/node-xmpp-browserify.js
at moduleError (/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/lib/wrap.js:405:16)
at Function.<anonymous> (/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/lib/wrap.js:444:19)
at Function.require (/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/index.js:156:28)
at /Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/lib/wrap.js:223:14
at Array.forEach (native)
at Function.<anonymous> (/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/lib/wrap.js:215:22)
at Function.addEntry (/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/index.js:156:28)
at /Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/bin/cmd.js:140:12
at Array.forEach (native)
at Object.<anonymous> (/Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/node_modules/node-xmpp/node_modules/browserify/bin/cmd.js:139:35)
npm ERR! [email protected] postinstall: `browserify -d -o node-xmpp-browser.js lib/node-xmpp-browserify.js`
npm ERR! `sh "-c" "browserify -d -o node-xmpp-browser.js lib/node-xmpp-browserify.js"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the node-xmpp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify -d -o node-xmpp-browser.js lib/node-xmpp-browserify.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-xmpp
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 12.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "node-xmpp"
npm ERR! cwd /Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.37
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] postinstall: `browserify -d -o node-xmpp-browser.js lib/node-xmpp-browserify.js`
npm ERR! message `sh "-c" "browserify -d -o node-xmpp-browser.js lib/node-xmpp-browserify.js"` failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/eelco/Projects/webinos/workspace/Webinos-Platform/webinos/common/xmpp/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1
When cloning the project and installing the required dependencies, I get the following problem for running the examples:
node echo_bot.js
node.js:205
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module './XML'
at Function._resolveFilename (module.js:318:11)
at Function._load (module.js:263:25)
at Module.require (module.js:341:17)
at require (module.js:352:17)
at Object. (/Users/pmu/projects/learning/nodejs/node-xmpp/lib/xmpp/stream_parser.js:4:11)
at Module._compile (module.js:416:26)
at Object..js (module.js:434:10)
at Module.load (module.js:335:31)
at Function._load (module.js:294:12)
at Module.require (module.js:341:17)
I'm experiencing some issues with node v.0.6.0. Just wanted to open the discussion.
Some files cause warnings: The "sys" module is now called "util". It should have a similar interface.
Also there's an issue with node-expat
as mentioned here: xmppo/node-expat#21
Could you please publish a fresh version of node-xmpp on npm to provide to npm users the recent great features such as the browserify support ?
Thank you.
As the title says, what do you suggest is the best way of detecting if the stream is ended because of loss of connectivity on either the client or server side?
I noticed the error
event is not triggered when this happens.
I tried binding myself to connection.socket.on('close')
, but it does not seem to be fired either.
Edit:
Even worse, if I make a remote connection to a XMPP server and disconnect myself from internet, I can still do connection.send
without any errors. It's as if socket.writeable
is still true
.
I tried binding myself to drain
and sending a whitespace, but the drain
triggered even if my socket isn't really connected.
Thanks!
Strophe.js gives the possibility to attach to an existing BOSH session given the rid and sid.
This can be useful when the session is initiated by a third party (an authentication server) or when we want to persist a connection during navigation (by storing sid/rid in cookies).
Do you plan to implement this kind of feature ?
var cl = new XMPP.Client({
boshURL: "https://beta.buddycloud.org/http-bind/",
jid: '[email protected]',
sid: 'someSid',
rid: '1573741822'});
Moreover an easy way to get the sid/rid would be appreciated too, for instance, to store them in a cookie. Since rid is incremented request after request, a convinient way would be event-oriented :
cl.addListener('boshIds', function(sid, rid) {
//do something with sid/rid
});
i read XEP-0077
if i wan to register i must send " iq " with get type, like:
ejabberd.send(new xmpp.Element('iq',{type:'get',id:'reg1',to:'test.server'}).c('query',{xmlns:'jabber:iq:register'}));
and i got result like this :
{ name: 'iq',
parent: null,
attrs:
{ from: '[email protected]',
to: '[email protected]/38928777511319686566520895',
id: 'reg1',
type: 'result',
xmlns: 'jabber:client',
'xmlns:stream': 'http://etherx.jabber.org/streams' },
children:
[ { name: 'query',
parent: [Circular],
attrs: [Object],
children: [Object] } ] }
with children like :
[ { name: 'instructions',
parent:
{ name: 'query',
parent: [Object],
attrs: [Object],
children: [Circular] },
attrs: {},
children: [ 'Choose a username and password to register with this server' ] },
{ name: 'username',
parent:
{ name: 'query',
parent: [Object],
attrs: [Object],
children: [Circular] },
attrs: {},
children: [ 'admin' ] },
{ name: 'password',
parent:
{ name: 'query',
parent: [Object],
attrs: [Object],
children: [Circular] },
attrs: {},
children: [] },
{ name: 'registered',
parent:
{ name: 'query',
parent: [Object],
attrs: [Object],
children: [Circular] },
attrs: {},
children: [] } ]
adn then i send this code ( like XEP-0077 example ) :
ejabberd.send(new xmpp.Element('iq',{type:'set',id:'reg1'}).c('query',{xmlns:'jabber:iq:register'}).c('username').t('alow').up().c('password').t('testa'));
why i got error result like this
[ { name: 'query',
parent:
{ name: 'iq',
parent: null,
attrs: [Object],
children: [Circular] },
attrs: { xmlns: 'jabber:iq:register' },
children: [ [Object], [Object] ] },
{ name: 'error',
parent:
{ name: 'iq',
parent: null,
attrs: [Object],
children: [Circular] },
attrs: { code: '403', type: 'auth' },
children: [ [Object] ] } ]
what i miss something....?
i already used super user in all code...
Trying to install node-xpp
npm install node-xmpp
[email protected] install /root/node-v0.4.9/node_modules/node-xmpp/node_modules/node-expat
node-waf configure build
Traceback (most recent call last):
File "/usr/local/bin/node-waf", line 14, in
import Scripting
ImportError: No module named Scripting
npm ERR! error installing [email protected] Error: [email protected] install: node-waf configure build
npm ERR! error installing [email protected] sh "-c" "node-waf configure build"
failed with 1
npm ERR! error installing [email protected] at ChildProcess. (/opt/local/node/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! error installing [email protected] Error: [email protected] install: node-waf configure build
npm ERR! error installing [email protected] sh "-c" "node-waf configure build"
failed with 1
npm ERR! error installing [email protected] at ChildProcess. (/opt/local/node/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] install: node-waf configure build
npm ERR! sh "-c" "node-waf configure build"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls node-expat
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 2.6.34.9-69.fc13.i686.PAE
npm ERR! command "node" "/opt/local/node/bin/npm" "install" "node-xmpp"
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/node-v0.4.9/npm-debug.log
npm not ok
Node: v0.49
NPM: v1.0.15
Cheers
Hi astro, I have a little bit of a situation when disconnecting that in some cases (I couldn't make a code that reproduces it constantly) if I send a <iq type='get'>
a moment before disconnecting, my nodejs app stops working with the following stack trace:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'end' of undefined
at Client.onEnd (.../node_modules/node-xmpp/lib/xmpp/connection.js:280:17)
at Socket.<anonymous> (.../node_modules/node-xmpp/lib/xmpp/connection.js:60:14)
at Socket.emit (events.js:88:20)
at Array.1 (net.js:319:25)
at EventEmitter._tickCallback (node.js:192:40)
What I do is send a msg and right after disconnect. It's not always that happens and when I tried to make a simple example to reproduce it I was not able to.
client.send(msg);
client.end();
What I thought is that this is caused because right after I send the </stream:stream>
stanza the server answers with a response to my iq before closing the connection (xmpp core allows this behaviour) but looking at the end function, you delete the streamOpened:
Connection.prototype.end = function() {
if (this.socket.writable) {
if (this.streamOpened) {
this.socket.write('</stream:stream>');
delete this.streamOpened;
} else {
this.socket.end();
}
}
};
If I do not delete the streamOpened there and delete it on the function onEnd
everything seems to work fine, like this:
Connection.prototype.onEnd = function() {
this.stopParser();
this.socket.end();
delete this.streamOpened;
};
Connection.prototype.end = function() {
if (this.socket.writable) {
if (this.streamOpened) {
this.socket.write('</stream:stream>');
} else {
this.socket.end();
}
}
};
Does this make sense? Am I doing something wrong? Doing this doesn't seem to break anything but maybe there is a better solution.
PS. actually. do not deleting this.streamOpened also works for disconnecting and everything else, but I assume I would be having a memory leak.
when running the example client echo_bot.js
i get this error:
$ node bot.js [email protected] foo
The 'sys' module is now called 'util'. It should have a similar interface.
node: /usr/local/include/node/node_object_wrap.h:30: static T* node::ObjectWrap::Unwrap(v8::Handlev8::Object) [with T = node::Buffer]: Assertion `handle->InternalFieldCount() > 0' failed.
Aborted
this happens in line 13 of the client:
var cl = new xmpp.Client({ jid: argv[2], password: argv[3] });
node is at tag v0.3.0
[email protected]
[email protected]
% ncat xmpp.msgboy.com. 5269 XML parse error XML parse error xXML parse errorxxxx XML parse errorXML parse error
tls.js:149
throw new Error('CryptoStream is not writable');
^
Error: CryptoStream is not writable
at CleartextStream.end (tls.js:149:11)
at Client.onEnd (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:226:17)
at CleartextStream.<anonymous> (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:50:14)
at CleartextStream.emit (events.js:39:17)
at SecurePair._destroy (tls.js:543:20)
at CleartextStream._done (tls.js:188:15)
at CleartextStream._pull (tls.js:312:12)
at SecurePair._cycle (tls.js:513:18)
at CleartextStream.end (tls.js:166:13)
at Client.end (/home/jpaulo/Desktop/testes/xmpp/node-xmpp_git/lib/xmpp/connection.js:238:25)
Hi, Astro.
When i send a message like sa'sa'1'sasa from Miranda client to node-xmpp client,
Node-xmpp client recieve this
children: [ 'sa', ''', 'sa', ''', '1', ''', 'sasa' ] }
text: sa,',sa,',1,',sasa
What is wrong?
Thank you.
is possible to replace node-waf to gyp?
examples/echo_bot.js doesn't appear to be receiving stanzas. I see that it should be receiving them in my server logs (Prosody), but the stanza handler is never triggered. By contrast, echo_component.js behaves just fine and does receive messages.
Im receiving a lot of errors... any ideia?:
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: socket hang up
at SecurePair.error (tls.js:802:15)
at CleartextStream._done (tls.js:283:17)
at CleartextStream._pull (tls.js:426:12)
at SecurePair.cycle (tls.js:727:20)
at CleartextStream.end (tls.js:256:13)
at Client.onEnd (/root/awesome-im/node_modules/node-xmpp/lib/xmpp/connection.js:279:17)
at Socket. (/root/awesome-im/node_modules/node-xmpp/lib/xmpp/connection.js:56:14)
at Socket.emit (events.js:88:20)
at TCP.onread (net.js:388:51)
node v0.8.1
npm 1.1.33
Getting the error:
Checking for header expat.h : not installed
expat.h exists at /usr/local/include/
Just not able to proceed further. Please help
using node-xmpp via node-xmpp-client project. It seems to be working very well. However if I idle on the TLS socket without any traffic the xmpp server kills the socket or something in the network does. I have it now doing an xmpp ping but was wondering would it be better to somehow set keepalive on the raw socket in node-xmpp ?
I do an extensive use of on("stanza", ...) Some of the listeners do actually alter the stanza object, which creates issues as later listeners will only have access to the alterred stanza :/
Is there a way to duplicate efficiently an object. I'm thinking I could use ltx to parse a serialized stanza, but it feels like a hack!
var xmpp = require('node-xmpp');
var cl = new xmpp.Client({jid : JID, password : PASSWORD, host : HOST});
cl.on('online', function () {
console.log("Came online");
cl.send(new xmpp.Element('presence', { }).c('show').t('chat').up().c('st
atus').t('Online!!!'));
this.end();
});
cl.on('offline', function () {
console.log("Came offline");
});
This code when I run with valid credentials gives the following output
Came online
and continues running. It never gets the 'offline' event as it should have. Any ways to resolve this?
It seems like node-expat is being built by npm for the wrong architecture?
Flags like the ones used in this article may be in order, but I'm not sure:
http://de-co-de.blogspot.com/2008/04/if-you-install-modjk.html
I am running snow leopard and node 0.3.0.
I'm guessing this is node-expat's problem rather than node-xmpp's problem. My bad for posting here.
Steps to reproduce:
DTrejo:nxmpp david$ git clone https://github.com/astro/node-xmpp.git Cloning into node-xmpp... remote: Counting objects: 856, done. remote: Compressing objects: 100% (288/288), done. remote: Total 856 (delta 561), reused 851 (delta 556) Receiving objects: 100% (856/856), 119.22 KiB | 174 KiB/s, done. Resolving deltas: 100% (561/561), done. DTrejo:nxmpp david$ npm install node-xmpp npm info it worked if it ends with ok npm info using [email protected] npm info using [email protected] npm info preinstall [email protected] npm info preinstall [email protected] npm info preinstall [email protected] npm info install [email protected] npm info postinstall [email protected] npm info preactivate [email protected] npm info activate [email protected] npm info postactivate [email protected] npm info install [email protected] npm info postinstall [email protected] npm info preactivate [email protected] npm info activate [email protected] npm info postactivate [email protected] npm info install [email protected] Checking for program g++ or c++ : /usr/bin/g++ Checking for program cpp : /usr/bin/cpp Checking for program ar : /usr/bin/ar Checking for program ranlib : /usr/bin/ranlib Checking for g++ : ok Checking for node path : ok /Users/david/.node_libraries Checking for node prefix : ok /Users/david/local 'configure' finished successfully (0.063s) Waf: Entering directory `/Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build' [1/2] cxx: node-expat.cc -> build/default/node-expat_1.o [2/2] cxx_link: build/default/node-expat_1.o -> build/default/node-expat.node Waf: Leaving directory `/Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build' 'build' finished successfully (0.393s) npm info postinstall [email protected] npm info preactivate [email protected] npm info activate [email protected] npm info postactivate [email protected] npm info build Success: [email protected] npm info build Success: [email protected] npm info build Success: [email protected] npm ok DTrejo:nxmpp david$ cd node-xmpp/ DTrejo:node-xmpp david$ node examples/ echo_bot.js echo_server.js send_message.js echo_component.js probe_server.js send_message_component.js DTrejo:node-xmpp david$ node examples/echo_server.js The 'sys' module is now called 'util'. It should have a similar interface. The 'sys' module is now called 'util'. It should have a similar interface. node.js:50 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: dlopen(/Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build/default/node-expat.node, 1): no suitable image found. Did find: /Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build/default/node-expat.node: mach-o, but wrong architecture at Object..node (node.js:362:13) at Module.load (node.js:279:25) at loadModule (node.js:251:12) at require (node.js:291:14) at Object. (/Users/david/local/lib/node/node-expat/index.js:11:18) at Module._compile (node.js:348:23) at Object..js (node.js:356:12) at Module.load (node.js:279:25) at loadModule (node.js:251:12) at require (node.js:291:14) DTrejo:node-xmpp david$ node --version v0.3.0
As I mentioned here I'm trying to get connected with facebook chat, but no errors, no online events.
I tried working with node-xmpp directly and I found out that here, that there's no <err>
but the <addrs>
is an empty array which is probably the problem. The name that was passed to function was <_xmpp-client._tcp.chat.facebook.com>
.
Since I don't know much with this awesome protocol, I have no idea what's going on. I tried the same thing with a jabber ID and password and it worked.
And onRawStanza wasn't called at all.
Any ideas?
I can connect and talk but getting an error on iq
elements.
Info:
Code:
new xmpp.Element('iq',
{
type : 'get',
from : '[email protected]',
id : new Date().getTime()
}).c('query',
{
xmlns : 'jabber:iq:roster'
});
Generated:
{ name: 'query',
parent:
{ name: 'iq',
parent: null,
attrs: { type: 'get', from: '[email protected]', id: 1334090949522 },
children: [ [Circular] ] },
attrs: { xmlns: 'jabber:iq:roster' },
children: [] }
Error:
/home/vagrant/bot/node_modules/node-xmpp/lib/xmpp/jid.js:30
throw new Error('Argument error');
^
Error: Argument error
at new JID (/home/vagrant/bot/node_modules/node-xmpp/lib/xmpp/jid.js:30:15)
at Client.<anonymous> (/home/vagrant/bot/bot.js:77:18)
at Client.emit (events.js:67:17)
at Client.onRawStanza (/home/vagrant/bot/node_modules/node-xmpp/lib/xmpp/client.js:159:14)
at Client.emit (events.js:67:17)
at Client.onStanza (/home/vagrant/bot/node_modules/node-xmpp/lib/xmpp/connection.js:237:14)
at StreamParser.<anonymous> (/home/vagrant/bot/node_modules/node-xmpp/lib/xmpp/connection.js:136:14)
at StreamParser.emit (events.js:67:17)
at [object Object].<anonymous> (/home/vagrant/bot/node_modules/node-xmpp/lib/xmpp/stream_parser.js:42:22)
at [object Object].emit (events.js:67:17)
I am seeing the following message back from NPM:
simon@simon-ubuntu64:~ $ sudo npm install node-xmpp
> [email protected] install /home/simon/node_modules/node-xmpp/node_modules/node-expat
> node-waf configure build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr
Checking for header expat.h : not installed
/home/simon/node_modules/node-xmpp/node_modules/node-expat/wscript:13: error: the configuration failed (see '/home/simon/node_modules/node-xmpp/node_modules/node-expat/build/config.log')
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf configure build"` failed with 1
npm ERR! error installing [email protected] at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf configure build"` failed with 1
npm ERR! error installing [email protected] at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] install: `node-waf configure build`
npm ERR! `sh "-c" "node-waf configure build"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls node-expat
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 2.6.38-11-generic
npm ERR! command "node" "/usr/bin/npm" "install" "node-xmpp"
npm ERR! cwd /home/simon
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.27
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/simon/npm-debug.log
npm not ok
The file /home/simon/node_modules/node-xmpp/node_modules/node-expat/build/config.log
is empty so I am not sure where to go from here.
node-xmpp requires an older version of node-expat (1.1.0) in npm. [email protected] installs fine, but node-xmpp insists on having the older version:
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info install [email protected]
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /home/stephej1/Library/node
'configure' finished successfully (0.020s)
Waf: Entering directory `/home/stephej1/Library/node/lib/node/.npm/node-expat/1.1.0/package/build'
[1/2] cxx: node-expat.cc -> build/default/node-expat_1.o
../node-expat.cc: In member function ‘bool Parser::parseBuffer(node::Buffer&, int)’:
../node-expat.cc:133: error: ‘class node::Buffer’ has no member named ‘data’
../node-expat.cc:133: error: ‘class node::Buffer’ has no member named ‘length’
Waf: Leaving directory `/home/stephej1/Library/node/lib/node/.npm/node-expat/1.1.0/package/build'
Build failed: -> task failed (err \#1):
{task: cxx node-expat.cc -> node-expat_1.o}
npm info [email protected] Failed to exec install script
npm ERR! install failed Error: [email protected] install: `./install.sh`
npm ERR! install failed `sh` failed with 1
npm ERR! install failed at ChildProcess.<anonymous> (/home/stephej1/Library/node/lib/node/.npm/npm/0.2.16/package/lib/utils/exec.js:25:18)
npm ERR! install failed at ChildProcess.emit (events.js:45:17)
npm ERR! install failed at ChildProcess.onexit (child_process.js:171:12)
npm info install failed rollback
npm info uninstall [ '[email protected]',
npm info uninstall '[email protected]',
npm info uninstall '[email protected]' ]
npm info preuninstall [email protected]
npm info preuninstall [email protected]
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info uninstall [email protected]
npm info uninstall [email protected]
npm info auto-deactive not symlink
npm info auto-deactive not symlink
npm info postuninstall [email protected]
npm info postuninstall [email protected]
npm info postuninstall [email protected]
npm info uninstall [email protected] complete
npm info uninstall [email protected] complete
npm info uninstall [email protected] complete
npm info install failed rolled back
npm ERR! Error: [email protected] install: `./install.sh`
npm ERR! `sh` failed with 1
npm ERR! at ChildProcess.<anonymous> (/home/stephej1/Library/node/lib/node/.npm/npm/0.2.16/package/lib/utils/exec.js:25:18)
npm ERR! at ChildProcess.emit (events.js:45:17)
npm ERR! at ChildProcess.onexit (child_process.js:171:12)
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./install.sh
npm ERR! You can get their info via:
npm ERR! npm owner ls node-expat
npm ERR! There may be additional logging output above.
npm not ok
Tell me please about subj
I'm getting this when trying to connect to Gtalk using echo_component.js example ...
<stream:error xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-streams"/></stream:error>
Of course, I'm pretty sure about the credentials I'm using.
If I use echo_bot, which uses Client class instead of Component, it apparently connects because the program does not exit, however no stanzas are received.
I know Gtalk uses SASL for authentication, maybe it's related to that, I don't know ... any ideas?
Thanks
Is there a way to enable client behind the firewall to be able to connect through http proxy ?
Running [email protected], [email protected] and [email protected] (no stringprep) on OSX 10.6, I'm getting the following error when I try to send a stanza using node-xmpp:
[path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:173
child.write(writer);
^
TypeError: Object 60 has no method 'write'
at [path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:173:23
at Array.forEach (native)
at Element.write ([path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:169:23)
at [path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:173:23
at Array.forEach (native)
at Element.write ([path]c/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:169:23)
at [path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:173:23
at Array.forEach (native)
at Element.write ([path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:169:23)
at [path]/local/lib/node/.npm/ltx/0.0.4/package/lib/element.js:173:23
This is the error.
if (!this.socket.writable)
^
TypeError: Cannot read property 'writable' of undefined
at [object Object].error (xmpp-server/node_modules/node-xmpp/lib/xmpp/connection.js:322:21)
at Socket.<anonymous> (xmpp-server/node_modules/node-xmpp/lib/xmpp/router.js:461:16)
at Socket.emit (events.js:64:17)
at Object._onTimeout (xmpp-server/node_modules/node-xmpp/lib/idle_timeout.js:11:16)
at Timer.ontimeout (timers.js:84:39)
I think I am finally able to understand what is going on.
In Router.prototype.setupStream
, a listener is attached to the socket for a C2S Stream. For some some reason, the C2S stream may be disconnected somewhere. If that happens, the socket is null-ed from the Connection (onClose event for example). Yet, the timeout may still be triggered on that socket. If that happens, the Router will then emit a 'connection-timeout', which will check of the socket of that connection is writeable... but since there is no socket. The error is triggered!
There are 2 ways to fix it :
Let me know what you think and I'll send a pull request!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.