strophe / strophejs Goto Github PK
View Code? Open in Web Editor NEWStrophe.js is an XMPP library for JavaScript
Home Page: http://strophe.im/strophejs
License: MIT License
Strophe.js is an XMPP library for JavaScript
Home Page: http://strophe.im/strophejs
License: MIT License
Hi,
Even though the base64 encoder works in most modern browsers, we had a problem with my password, when it base64 encodes it via an older browser (Ant galio).
The problem lies in the way not-a-number (NaN) is handled.
In Chrome and other modern browsers shifting NaN gives 0. Whereas in Ant Galio: NaN >> 4 yields e.g. -134217728 (random undefined number in memory).
So in case of enc2 = ((chr1 & 3) << 4) | (chr2 >> 4) it will effectively give: enc2 = ((chr1 & 3) << 4)
The fix is therefore straight forward. In line 30/31 in base64.js (master), we just need to take care of the encoded2 part. So adding this one line in base64.js will fix it. Of course it still works flawless in all the modern browsers as well. :-)
if (isNaN(chr2)) {
enc2 = ((chr1 & 3) << 4); // this line need to be added
enc3 = enc4 = 64;
}
I open this discussion to pursue the one in metajack's branch (metajack/strophejs#68)
I agree with michfield, I would also suggest to merge @Gordin branch.
Is there any reason not to merge this branch/support websocket in strophe yet?
When the XMPP server is down and a client try to connect, after 5 attempts it call the _doDisconnect method.
_doDisconnect: function ()
{
/* ... */
// tell the parent we disconnected
if (this.connected) {
this._changeConnectStatus(Strophe.Status.DISCONNECTED, null);
this.connected = false;
}
/* ... */
},
The problem is that the _changeConnectStatus is surrounded by a this.connected check and Strophe will stay forever in a connecting status.
What the point of this check ? Could it be removed without any side effect ?
I created a pull request in the old repository for AMD support (metajack/strophejs#99). Is this something that people are interested in? I can rebase my changes on the current master if so and submit a PR.
Hi,
I got following javascript error, when i try to login converse.js. when i run separately, it works fine.
When i integrate with my application it make the problem. I think the problem is with "Function.prototype.bind" in strophe.js. Can you please help me to fix this.
TypeError: req is undefined @ http://localhost:8033/js/converse/components/strophe/strophe.js:3045
_onRequestStateChange: function (func, req)
{
Strophe.debug("request id " + req.id +
"." + req.sends + " state changed to " +
req.xhr.readyState);
Thanks in advance.
I've been looking into XMPP implementations and whether they verify the source of iq replies. See http://mail.jabber.org/pipermail/jdev/2014-January/089824.html and http://mail.jabber.org/pipermail/jdev/2014-January/089838.html for more discussion.
The sendIQ
function in https://github.com/strophe/strophejs/blob/master/src/core.js#L1938 does not verify whether the from
on an incoming iq packet matches the to
from the outgoing packet. This means for example that a roster reply is not checked to actually originate from the user's server. An attacker can, if timed right, spoof the roster for a user by making sure their fake reply reaches strophe before the real reply does. This can also lead to spoofing of vcards, intercepting file transfers, etc.
I have verified that calling connection.roster.get(function (roster) ... )
does indeed cause the callback to be called even when the origin is not the user's server.
version 1.1.3 and 1.1.2 are shown in 2013 and should be 2014 :)
It seems that the version 1.1.1 still doesn't support synchronous disconnect: metajack/strophejs#16.
I have this same issue on several projects where I need to disconnect a user and reconnect it with different credentials and the XMPP connection freezes on the CONNECTING status.
the original repo was https://github.com/metajack/strophejs and there are 13 pending pull requests. I would like to have a status about these.
thanks
Hello guys.
I have a noob question - I'm working on ban list admin tool. Can someone tell me how is the response from the iq request parsed, as I need to populate the list. I've managed to create the iq request and to recieve the list of baned users ... but how and more precisly where can I populate the table?
[Error] TypeError: 'undefined' is not a function (evaluating 'that._buildBody()')
connect (strophe.register.js, line 106)
It is possible to have a XEPs and RFCs support page with version (XEP-XXXX v1.2)?
Examples:
I do:
var h = connection.addHandler(...)
connection.deleteHandler(h);
...and the handler is working (it should not).
The url is currently pointing at metajacks repository. It should be pointing at this repo.
I have seen that when we login to xmpp server using jid(jabber id)
after successful login our connection.jid
and our loginjid
is difference some extra information is added like jid@somedomain/randomvalue
.
I want to know that is that extra part and what is the significance of that in xmpp chat.
We started to use Strophe 1.0.2 but encountered a bug related to double-escaping which is specific to this version and is already fixed in the master branch. We then tried to revert to 1.0.1, but without success, because of a problem when disconnecting which is also already fixed in master.
Are you planning to release version 1.0.3 anytime soon? We use bower for the project dependencies and would like to add the new version to the bower-strophejs repo.
We use strophe.js in our application, after some minutes in Chrome/IE (not in Firefox) when the application try to reconnect , strophe.js throw the following exception
Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.
according to SO http://stackoverflow.com/questions/17182816/ajax-php-javascript-error-when-using-post-method it seems the solution is to add
req.xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
just after the req.xhr.open
(line 2247)
when I try to register from web client using locally hosted openfire I got registration failed without any error notification or error stanza .
What is the reason behind this registration failed?
I have response of message below:
SENT: <body rid='2426896877' xmlns='http://jabber.org/protocol/httpbind' to='localhost' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind' xmlns:stream='http://etherx.jabber.org/streams' authid='99f5151b' sid='99f5151b' secure='true' requests='2' inactivity='30' polling='5' wait='60' hold='1' ack='2426896877' maxpause='300' ver='1.6'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5<mechanism>JIVE-SHAREDSECRET<mechanism>PLAIN<mechanism>ANONYMOUS<mechanism>CRAM-MD5<compression xmlns='http://jabber.org/features/compress'>zlib<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></stream:features></body>
For example:
stropheobj = new Strophe.Connection(url);
stropheobj.connect("[email protected]", "testpwd", connectHandler); // Passed
stropheobj.disconnect();
stropheobj.connect("[email protected]", "testpwd", connectHandler); // Passed
stropheobj.disconnect();
// Failed, because it actually connect with '[email protected]'.
stropheobj.connect("[email protected]", "testpwd", connectHandler);
I found the source code of src/core.js line 1753 may caused this problem https://github.com/strophe/strophejs/blob/master/src/core.js#L1753
this.domain = this.domain || Strophe.getDomainFromJid(this.jid);
I do not know if this is a bug?
Every browser has a concurrent connection limit to a domain. To avoid this and allow multiple connection from each browser's tab, we should allow wildcard in connection uri: first browser's tab would connect to myservice1.mywebsite.com, second myservice2.mywebsite.com, n myserviceN.mywebsite.com.
What do you think about?
Hi,
by accident I ran a jshint on the Strophe source files and it seems that the code contains quite some unused and undefined variables (among other things).
I think it would be good to define a .jshintrc
file with the Strophe standards and clean up the things.
Example output:
src/base64.js: line 5, col 11, 'Base64' is defined but never used.
src/bosh.js: line 8, col 1, Bad option value.
src/bosh.js: line 419, col 56, Don't make functions within a loop.
src/bosh.js: line 441, col 13, 'body' is not defined.
src/bosh.js: line 442, col 18, 'i' is not defined.
src/bosh.js: line 442, col 25, 'i' is not defined.
src/bosh.js: line 442, col 42, 'i' is not defined.
src/bosh.js: line 443, col 26, 'i' is not defined.
src/bosh.js: line 444, col 30, 'i' is not defined.
src/bosh.js: line 445, col 25, 'body' is not defined.
src/bosh.js: line 452, col 25, 'body' is not defined.
src/bosh.js: line 452, col 41, 'i' is not defined.
src/bosh.js: line 459, col 37, 'body' is not defined.
src/bosh.js: line 462, col 37, 'body' is not defined.
src/bosh.js: line 467, col 13, 'time_elapsed' is not defined.
src/bosh.js: line 475, col 17, 'time_elapsed' is not defined.
src/bosh.js: line 12, col 41, 'document' is defined but never used.
src/bosh.js: line 12, col 41, 'console' is defined but never used.
src/bosh.js: line 12, col 41, 'Base64' is defined but never used.
src/bosh.js: line 12, col 41, 'MD5' is defined but never used.
src/bosh.js: line 12, col 41, '$msg' is defined but never used.
src/bosh.js: line 12, col 41, '$iq' is defined but never used.
src/bosh.js: line 12, col 41, '$pres' is defined but never used.
src/core.js: line 8, col 1, Bad option value.
src/core.js: line 1601, col 35, Don't make functions within a loop.
src/core.js: line 575, col 13, 'parser' is not defined.
src/core.js: line 575, col 26, 'DOMParser' is not defined.
src/core.js: line 576, col 13, 'node' is not defined.
src/core.js: line 576, col 20, 'parser' is not defined.
src/core.js: line 578, col 13, 'node' is not defined.
src/core.js: line 579, col 13, 'node' is not defined.
src/core.js: line 580, col 13, 'node' is not defined.
src/core.js: line 582, col 16, 'node' is not defined.
src/core.js: line 3157, col 18, 'core_hmac_sha1' is not defined.
src/core.js: line 3159, col 11, 'core_hmac_sha1' is not defined.
src/core.js: line 3159, col 43, 'binb2str' is not defined.
src/core.js: line 3165, col 10, 'binb2str' is not defined.
src/core.js: line 3167, col 17, 'core_hmac_sha1' is not defined.
src/core.js: line 3168, col 17, 'str_hmac_sha1' is not defined.
src/core.js: line 3169, col 23, 'core_hmac_sha1' is not defined.
src/core.js: line 3169, col 38, 'str_sha1' is not defined.
src/core.js: line 3169, col 47, 'binb2str' is not defined.
src/core.js: line 3170, col 49, 'b64_hmac_sha1' is not defined.
src/core.js: line 3176, col 43, 'binb2str' is not defined.
src/core.js: line 661, col 94, 'children' is defined but never used.
src/core.js: line 661, col 101, 'child' is defined but never used.
src/core.js: line 866, col 30, 'msg' is defined but never used.
src/core.js: line 866, col 25, 'level' is defined but never used.
src/core.js: line 1807, col 29, 'elem' is defined but never used.
src/core.js: line 1830, col 30, 'elem' is defined but never used.
src/core.js: line 1847, col 29, 'data' is defined but never used.
src/core.js: line 1864, col 30, 'data' is defined but never used.
src/core.js: line 2396, col 30, 'auth_str' is defined but never used.
src/core.js: line 2396, col 47, 'hashed_auth_str' is defined but never used.
src/core.js: line 2537, col 30, 'elem' is defined but never used.
src/core.js: line 2751, col 37, 'elem' is defined but never used.
src/core.js: line 2900, col 17, 'body' is defined but never used.
src/core.js: line 2900, col 31, 'time_elapsed' is defined but never used.
src/core.js: line 2992, col 28, 'connection' is defined but never used.
src/core.js: line 3018, col 46, 'challenge' is defined but never used.
src/core.js: line 3018, col 35, 'connection' is defined but never used.
src/core.js: line 3072, col 73, 'challenge' is defined but never used.
src/core.js: line 3267, col 53, 'challenge' is defined but never used.
src/core.js: line 3267, col 42, 'connection' is defined but never used.
src/core.js: line 12, col 41, 'XMLHttpRequest' is defined but never used.
src/core.js: line 12, col 41, 'Strophe' is defined but never used.
src/core.js: line 12, col 41, '$build' is defined but never used.
src/core.js: line 12, col 41, '$msg' is defined but never used.
src/core.js: line 12, col 41, '$iq' is defined but never used.
src/core.js: line 12, col 41, '$pres' is defined but never used.
src/md5.js: line 14, col 8, 'MD5' is defined but never used.
src/sha1.js: line 16, col 18, 'b64_sha1' is defined but never used.
src/sha1.js: line 17, col 18, 'str_sha1' is defined but never used.
src/sha1.js: line 18, col 23, 'b64_hmac_sha1' is defined but never used.
src/sha1.js: line 19, col 23, 'str_hmac_sha1' is defined but never used.
src/websocket.js: line 106, col 9, 'ns' is not defined.
src/websocket.js: line 107, col 14, 'i' is not defined.
src/websocket.js: line 107, col 21, 'i' is not defined.
src/websocket.js: line 107, col 50, 'i' is not defined.
src/websocket.js: line 108, col 13, 'e' is not defined.
src/websocket.js: line 108, col 34, 'i' is not defined.
src/websocket.js: line 109, col 17, 'e' is not defined.
src/websocket.js: line 109, col 45, 'ns' is not defined.
src/websocket.js: line 111, col 19, 'e' is not defined.
src/websocket.js: line 112, col 24, 'e' is not defined.
src/websocket.js: line 114, col 29, 'e' is not defined.
src/websocket.js: line 118, col 9, 'errorString' is not defined.
src/websocket.js: line 121, col 13, 'errorString' is not defined.
src/websocket.js: line 123, col 13, 'errorString' is not defined.
src/websocket.js: line 127, col 13, 'errorString' is not defined.
src/websocket.js: line 130, col 23, 'errorString' is not defined.
src/websocket.js: line 160, col 27, 'WebSocket' is not defined.
src/websocket.js: line 238, col 35, 'DOMParser' is not defined.
src/websocket.js: line 254, col 70, 'error' is not defined.
src/websocket.js: line 259, col 28, 'DOMParser' is not defined.
src/websocket.js: line 275, col 40, 'WebSocket' is not defined.
src/websocket.js: line 394, col 18, 'i' is not defined.
src/websocket.js: line 394, col 25, 'i' is not defined.
src/websocket.js: line 394, col 42, 'i' is not defined.
src/websocket.js: line 395, col 26, 'i' is not defined.
src/websocket.js: line 397, col 30, 'i' is not defined.
src/websocket.js: line 402, col 39, 'i' is not defined.
src/websocket.js: line 439, col 13, 'data' is not defined.
src/websocket.js: line 440, col 24, 'DOMParser' is not defined.
src/websocket.js: line 440, col 52, 'data' is not defined.
src/websocket.js: line 446, col 13, 'data' is not defined.
src/websocket.js: line 447, col 24, 'DOMParser' is not defined.
src/websocket.js: line 447, col 52, 'data' is not defined.
src/websocket.js: line 342, col 29, 'event' is defined but never used.
src/websocket.js: line 11, col 41, 'setTimeout' is defined but never used.
src/websocket.js: line 11, col 41, 'console' is defined but never used.
src/websocket.js: line 11, col 41, 'XMLHttpRequest' is defined but never used.
src/websocket.js: line 11, col 41, 'ActiveXObject' is defined but never used.
src/websocket.js: line 11, col 41, 'Base64' is defined but never used.
src/websocket.js: line 11, col 41, 'MD5' is defined but never used.
src/websocket.js: line 11, col 41, '$msg' is defined but never used.
src/websocket.js: line 11, col 41, '$iq' is defined but never used.
src/websocket.js: line 11, col 41, '$pres' is defined but never used.
118 errors
While for sure some of them are entirely just global definitions which are missing in the source files, there are also very valid ones and IMO we should fix them to make Strophe more robust and also (in case of the unused variables) less big in the size.
Do you agree with me?
Why do we have a separate plugin folder within this repository? Can we move strophe.flxhr.js
to the strophejs-plugins repo?
Is it possible to get the last RID and store it into local storage so I can continue the session after the page reload? I always get disconnected every time I do a few page reload.
Any suggestions?
i want to to transfer file using si file transfer plugin.
When using SASL Digest-MD5 mechanism, the user will recieve a bad-protocol error because the second challenge response will be:
<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>AA==</response>
instead of:
<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'></response>
I believe I have traced this down to the Base64 encode implementation. In Base64.js the encode function is implemented as a do while(), this means that the empty challenge response of "" gets encoded to AA== which then gets sent to the server and results in failure. This implementation of Base64 encoding does not cause this error.
http://www.webtoolkit.info/javascript-base64.html#.Up0Pr8Try4E
Why is that? I noticed it in my review, but forgot to mention it.
pinging @Gordin
Hi, I have problems with 3G connection to xmpp server. When I try to login, status change to connecting but nothing more happens. Over WiFi connection all works well and with native apps (no web/js code) connection works.
Greetings!!
Strophe does not return a disconnect in case the URL being connected to is unreachable, it is trying reconnect 5 times but at the end of the retries, no disconnect event is passed to the calling API.
I tried connecting to an unavailable URL for fail over testing of my application, but in case the server is unresponsive I do not get a disconnect...here are the logs.
11:39:14.131 "start" poc:9
11:39:39.646 POST http://server.unreachable.com/ [669ms]
11:39:39.589 "Strophe:0:request id 1.1 state changed to 2" poc:29
11:39:39.590 "Strophe:0:request id 1.1 state changed to 4" poc:29
11:39:39.590 "Strophe:3:request id 1.1 error 0 happened" poc:29
11:39:39.590 "Strophe:2:request errored, status: 0, number of errors: NaN" poc:29
11:39:39.590 "Strophe:0:_throttledRequestHandler called with 1 requests" poc:29
11:39:39.591 "Strophe:0:request id 2.1 posting" poc:29
11:39:39.592 "Strophe:0:request id 2.1 state changed to 1" poc:29
11:40:01.261 "Strophe:0:request id 2.2 state changed to 2" poc:29
11:40:01.261 "Strophe:0:request id 2.2 state changed to 4" poc:29
11:40:01.261 "Strophe:3:request id 2.2 error 0 happened" poc:29
11:40:01.262 "Strophe:2:request errored, status: 0, number of errors: NaN" poc:29
11:40:01.262 "Strophe:0:_throttledRequestHandler called with 1 requests" poc:29
11:40:01.263 "Strophe:0:request id 3.2 posting" poc:29
11:40:01.263 "Strophe:0:request id 3.2 state changed to 1" poc:29
11:40:09.317 POST http://server.unreachable.com/ [255ms]
11:40:43.508 "Strophe:0:request id 3.3 state changed to 2" poc:29
11:40:43.509 "Strophe:0:request id 3.3 state changed to 4" poc:29
11:40:43.509 "Strophe:3:request id 3.3 error 0 happened" poc:29
11:40:43.509 "Strophe:2:request errored, status: 0, number of errors: NaN" poc:29
11:40:43.510 "Strophe:0:_throttledRequestHandler called with 1 requests" poc:29
11:40:43.510 "Strophe:0:request id 4.3 posting" poc:29
11:40:43.511 "Strophe:0:request id 4.3 state changed to 1" poc:29
11:41:10.564 POST http://server.unreachable.com/ [255ms]
11:41:33.270 "Strophe:0:request id 4.4 state changed to 2" poc:29
11:41:33.270 "Strophe:0:request id 4.4 state changed to 4" poc:29
11:41:33.270 "Strophe:3:request id 4.4 error 0 happened" poc:29
11:41:33.270 "Strophe:2:request errored, status: 0, number of errors: NaN" poc:29
11:41:33.271 "Strophe:0:_throttledRequestHandler called with 1 requests" poc:29
11:41:33.271 "Strophe:0:request id 5.4 posting" poc:29
11:41:33.271 "Strophe:0:request id 5.4 state changed to 1" poc:29
11:42:37.326 POST http://server.unreachable.com/ [730ms]
11:43:19.756 "Strophe:0:request id 5.5 state changed to 2" poc:29
11:43:19.757 "Strophe:0:request id 5.5 state changed to 4" poc:29
11:43:19.757 "Strophe:3:request id 5.5 error 0 happened" poc:29
11:43:19.757 "Strophe:2:request errored, status: 0, number of errors: NaN" poc:29
11:43:19.757 "Strophe:0:_throttledRequestHandler called with 1 requests" poc:29
11:43:19.758 "Strophe:0:request id 6.5 posting" poc:29
11:43:19.758 "Strophe:0:request id 6.5 state changed to 1" poc:29
11:44:25.812 POST http://server.unreachable.com/ [666ms]
11:45:08.188 "Strophe:0:request id 6.6 state changed to 2" poc:29
11:45:08.188 "Strophe:0:request id 6.6 state changed to 4" poc:29
11:45:08.189 "Strophe:0:removing request" poc:29
11:45:08.189 "Strophe:0:_throttledRequestHandler called with 0 requests" poc:29
11:45:08.189 "Strophe:0:request id 6 should now be removed" poc:29
11:45:08.189 "Strophe:3:request id 6.6 error 0 happened" poc:29
11:45:08.190 "Strophe:2:request errored, status: 0, number of errors: NaN" poc:29
The disconnect never gets called.
Strophe tries re connection 5 times but no disconnect event is sent, This is a problem for us because we want to reconnect to another URL in case one is down, so we need a signal whenever strophe fails to connect.
In case of unreachable URLs the reqStatus variable in _onRequestStateChange function becomes 0.
Ideally after 5 retries a disconnect should be sent for this state [for that matter it should be sent for every possible state]. Like a disconnect is being sent for reqStatus >= 400 && reqStatus < 500.
https://github.com/strophe/strophejs/blob/master/src/core.js#L1774
.attach is calling this.proto.attach instead of this.proto._attach
Hi Guys,
Should we not bump up the version to 1.0.3 or 1.1.0 (because of the major changes) and update the Changelog? Websockets have been implemented and core.js and a lot of other changes have happened.
Right now it seems like a mess. If you already have 1.0.2 you do not think that something have happened since that.
I don't know where to place the addHandler statements. Anywhere I try, problems errupt. deleteHandler doesn't seem to be doing anything. And I'll file a bug about this soon. So I have this question for the developers (the answer is not in the documentation, so please answer):
If I execute Connection.connect(...) 10 times while disconnected, and then the connection happens, how many times will the function(status) callback be executed every time the status changes from then on?
on disconnect doesn't close connection server side... the disconnect function acts on a null socket so it fails to actually close the websocket
It looks like the latest Strophe has some issues with dealing with reconnects due to what appear to be one or more bugs in the new code.
Firstly the hitError function:
_hitError: function (reqStatus)
{
this.errors++;
Strophe.warn("request errored, status: " + reqStatus +
", number of errors: " + this.errors);
if (this.errors > 4) {
this._onDisconnectTimeout();
}
},
This now lives in Strophe.Bosh, however errors is only initialised to 0 in Strophe.Connection, so errors is NaN here, and onDisconnectTimeout() is therefore never called.
However, even with this fixed, it seems there is another issue in onDisconnectTimeout, which in the latest code looks like this:
_onDisconnectTimeout: function ()
{
var req;
while (this._requests.length > 0) {
req = this._requests.pop();
req.abort = true;
req.xhr.abort();
// jslint complains, but this is fine. setting to empty func
// is necessary for IE6
req.xhr.onreadystatechange = function () {}; // jshint ignore:line
}
},
The old version of strophe looked like this:
_onDisconnectTimeout: function ()
{
Strophe.info("_onDisconnectTimeout was called");
// cancel all remaining requests and clear the queue
var req;
while (this._requests.length > 0) {
req = this._requests.pop();
req.abort = true;
req.xhr.abort();
// jslint complains, but this is fine. setting to empty func
// is necessary for IE6
req.xhr.onreadystatechange = function () {};
}
// actually disconnect
this._doDisconnect();
return false;
},
So the old version explicitly called doDisconnect which reset the state to DISCONNECTED allowing any code that was designed to listen to this , and attempt to reconnect to get called.
What appears to happen now is that after max errors is reached attempt to reconnect, strophe simply stops trying, without raising any state change that could alert the programmer that they now need to explicitly try to reconnect, as strophe has now officially given up the attempt.
What I do to reproduce this problem is:
I have removed the backoff on resend (or rather set it to a fixed 5000 ms) which speeds up the reproduction of the problem, but may be creating other issue, although AFAIKs the code mentioned above has problems irrespective of this.
I attempted to put the doDisconnect call back in
_onDisconnectTimeout, but had some issues with that (seemed I ended up with two attempts to reconnect, but that may have been a bug in my own reconnect code).
Note that the error I get in this code, and the code calling hitError:
if (reqStatus === 0 ||
(reqStatus >= 400 && reqStatus < 600) ||
reqStatus >= 12000) {
this._hitError(reqStatus);
if (reqStatus >= 400 && reqStatus < 500) {
this._conn._changeConnectStatus(Strophe.Status.DISCONNECTING,
null);
this._conn._doDisconnect();
}
}
is reqStatus 0. If I was getting an error code in the 400 to 500 range, this would probably all work, but the 0 reqStatus code means the push into disconnecting state, and call to doDisconnect doesn't happen (which makes sense, but the hitError then needs to be able to eventually trigger a doDisconnect I think).
Please let me know if you need more details.
With websockets, if there's absolutely no traffic for 60 seconds then the connection gets dropped, and I think that's caused by Strophe, not the XMPP server, am I right?
In either case, I don't see my Strophe connection's callback get called, despite the fact that the connection's status changed (so I would need to update the browser's display).
But maybe it's the server that's doing it, and it's dropping the connection so silently that Strophe doesn't notice.
Is that the case? Please advise.
Similarly, I tried stopping my server process completely, so obviously the Strophe client must have disconnected, yet connect's callback wasn't called. Is it because Strophe doesn't want the connection to be deemed as closed just because of a temporary disconnect?
If that's the case, how do I configure Strophe to consider websocket disconnect as a disconnect from the server? Because that's how I've configured my server (a temporary disconnect will close the session).
Also, how do I configure how much time needs to pass before Strophe considers a connection as disconnected?
Also, how do I change the 60-seconds timeout duration?
connection
is my jabber connection variable, handler
is my handler variable which I got as a return value from the last addHandler
, and so I run: connection.deleteHandler(handler)
and absolutely nothing happens, the handler doesn't disappear, the handler just keeps on handling.
I tried it many times, and I'm positive I'm right. I kindly ask you to try it on a websockets jabber connection.
Last time I posted this error, someone told me: "put it up on a plnkr, and show us" - but I would have to post a Jabber user's credentials in public to do that. I would also need to find to Jabber server open to registrations that also won't be angry if I post my credentials in public. So I ask you, please, try it once, and if it fails then tell me to post it in public. But it won't fail, I'm positive. You'll see.
Hi,
I'm using Strophe.js AMD with the Register plugin (works perfect so far) and I have noticed that the addHandler method/function does not get fired until the connection status becomes CONNECTED?
I can understand why you would have it firing up AFTER being connected, but I think in the case of registration, it would be useful to have this method fire up at any given stage (i.e. before being connected) so that you can analyse the server response more accurately and better instead of relying on the CONNECTION status.
Quite frustrating when you realise that you have to work with the RAW OUTPUT instead of the addHandler method.
Please see the register plugin page where it shows you how to deal with server response (which is now the right way to do IMO): https://github.com/metajack/strophejs-plugins/tree/master/register
If anybody else has encountered this issue, please comment and share your thoughts and solutions.
Farax
i have been dealing with these issue for a while and i could not get any result. I want to resume the connection when the page is refresh. I use the attach function, but for some reason it fails to load the presence of each roster. Please need help. I could see from the console that the it has queried the roster but the connection stops there.
Is this possible to I attach Strophe to a an existing session via websockets?
I need this to auto-login users that are already logged in an app.
I noticed that sometimes when I call connection.disconnect(), the handlers disappear (when I reconnect, the handlers are not there). But not always.
I would like to know when Handlers get flushed away, so I can plan my software accordingly.
Thanks
Responses from the server come with Content-Type=text/xml
I noticed this in wireshark watching candy traffic, when it shows server responses as XML and parses them, but only shows client messages as text.
This is not a major problem, but it better be fixed.
Hi,
I'm starting a project that requires to develop a client side xmpp chat. I found node-xmpp
and strophe.js
. After some research, it is not perfectly clear which one I should pick.
Can you explain what the main differences are and which one is most suited for browser development?
Thanks a lot
I am using strophe for the web and punjab and openfire for the server.
My strophejs version is master from source. I've been experiencing weird occurrences for session binding. If I send a message and reload the session suddenly gets dropped. When I just keep refreshing no message sent, All goes well.
I also noticed that the rid keep increment correctly but there are also times that it goes back to the first rid. I have put the initial rid and sid on a cookie, then I use those data on my javascript code.
It is just weird that sometimes it works well, and sometimes it does not. Or maybe I do not understand pre-binding very well. It pre-binding done like authenticate together with the web login then store the rid,sid and jid in cookie. That cookie will be reused by the strophe on each page reload? Or do I have to prebind every page refresh?
Another weird thing is that strophe sends multiple messages when I send one message and reload the page immediately after sending. It sends like 2 or 3 dupes and the RID's are all the same. After that I lost connection.
But when I view the page (without sending anything) and keep on reloading it, everything works well. Still keeps sending dupes, but also not getting disconnected.
Hi! I'm doing a security review of Cryptocat, which uses Strophe (https://github.com/cryptocat/cryptocat/blob/master/src/core/js/lib/strophe/strophe.js). I see that getUniqueId is documented as "The counter resets to 0 for every new connection for the same reason." (the reason being nicer debug messages, especially when looking at multiple similar runs), but the implementation (
Line 1653 in 0f67826
I was working on converse plugin(for php and Openfire) for Multi user chat. But there is one restriction on line number 1338, that checks if stanza has type attribute or not, and it filter outs such stanzas. So in muc chat we were not gettings messages of new room. Can you please check this issue? I have removed that line in my code and its working fine. Please check the code of isMatch function in strophe.js. I know this attribute is optional but recommended, but still so many chat clients are not supporting this attribute. Let me know if I can help with this. Thanks
If the first request (not an empty polling request) from queue hangs (does not get response immediately because of request size, network delay, whatever), then it makes possible to send as many subsequent requests from queue as possible till the first request gets response at last. This, in turn, is causing session drop with item-not-found error (http status 404).
This is caused by calling _processRequest()
directly from _onIdle()
instead of calling _throttledRequestHandler()
(here is fix):
3572c3572
< this._throttledRequestHandler();
---
> this._processRequest(this._requests.length - 1);
XMPP Resource bind, doesn't allow other elements to be returned, and it assumes that bind is immediately returned which makes the server have to do a synchronous response for bind, which is not correct. It means that offline messages can't be flushed at that point in time.
EM
Test case/demo:
https://gist.github.com/lpetrov/8351277
Expected to see both calls to result in a Connected message in the console.
What I got instead, was Auth fail for the first call and Connected for the second one.
I'd tried to trace the problem, but it got really messy when i got into the SASLSHA1's onChallenge black magic :)
The most interesting thing that I'd found is that both AUTH stanzas are almost identical (same generated hashes).
So, maybe this has to do something with the global (missing 'var') variables somewhere in the code?
For now, my solution is to disable the SASLSHA1 locally and use MD5.
Hi there, I see 'xmlescape' method in library, but there isn't 'xmlunescape' method
Can you please add it, here is an implementation
/* Function: xmlunescape
* Unexcapes invalid xml characters.
*
* Parameters:
* (String) text - text to unescape.
*
* Returns:
* Unescaped text.
*/
xmlunescape: function(text)
{
text = text.replace(/\&/g, "&");
text = text.replace(/</g, "<");
text = text.replace(/>/g, ">");
text = text.replace(/'/g, "'");
text = text.replace(/"/g, "\"");
return text;
},
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.