conversejs / converse.js

Web-based XMPP/Jabber chat client written in JavaScript
http://conversejs.org
Mozilla Public License 2.0
3.08k stars 771 forks source link

Converse is flooding my XMPP server. #318

Closed rubsilva closed 9 years ago

rubsilva commented 9 years ago

Hi there.

I'm having an issue with converse and tigase xmpp server related with too many POST requests launched by converse.

I dont know if this is related with something wrong in server side (tigase), but as i am seeing requests coming out from converse, my first impression is that is related with converse, apologies if i am wrong.

So my setup is:

When i point my browser to myserver.com/index.php?name=NAME&pass=PASS, i was expecting to see converse login me in, shows all my contacts and wait. Instead, converse logs me in, shows my contacts and starts to make enumerous POST requests to XMPP server, like in a loop, flooding my xmpp server with requests. Curiously, if i reload the page, all seems to stay fine from there on.

I attached some log files from firebug that show whats happening. Please wget (https://cloud.githubusercontent.com/assets/5545587/6109600/d4114dae-b073-11e4-9f2e-0d4aed25017b.jpg) the image and rename it to *.zip to see the files (as i cant upload archives) converse

Thank you

edudemy commented 9 years ago

Also, check whether apache is set to proxy http requests to corresponding xmpp port.

Candy documentation: http://candy-chat.github.io/candy/#setup

rubsilva commented 9 years ago

Hi

My apache configuration in sites-available/000-default.conf is:

<VirtualHost *:80>
    DocumentRoot /var/www/
    <Location /http-bind>
        Order allow,deny
        Allow from all
    </Location>
    RewriteEngine On
    RewriteRule ^/http-bind$ http://localhost:5280/http-bind [P,L]

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined
</VirtualHost>
jcbrand commented 9 years ago

BOSH relies on long-polling, which means when the client (converse.js) makes an XMLHTTPRequest to the BOSH server, the BOSH server needs to hold open the request and only return a response when it has new information.

https://en.wikipedia.org/wiki/Push_technology#Long_polling

It looks like what might be happening here is that the BOSH server is not holding on to the request but instead returning a response immediately. Converse.js (more specificially Strophe.js) will then simply make another XMLHTTPRequest.

Either that, or the BOSH server is holding on to the request and converse.js for some reason keeps on sending new requests.

Firstly, make sure you are using the unminified converse.js file from the ./builds/ directory.

Then, look for this code (I'm linking to Strophe.js, but the same code is in the bundle): https://github.com/strophe/strophejs/blob/4db59462fdd1232da59bd9bf98fcec81104c4693/src/bosh.js#L74

Put a breakpoint in getResponse and check if you get a response immediately after a request is sent.

rubsilva commented 9 years ago

Ok, will try that out,

rubsilva commented 9 years ago

Well, it seems that you are right, i get a response immediately after a request is made. After the first connect, there seems to be a strange message response from the server with many iq tags on it, i dont know why tigase behaves like that:

Request:
<body rid='7129396871' xmlns='http://jabber.org/protocol/httpbind' sid='eb62ed9b-df5a-49b9-8795-0fe081c71dd6'><iq from='user2@chat.myserver.com' id='enablecarbons' type='set' xmlns='jabber:client'><enable xmlns='urn:xmpp:carbons:2'/></iq><iq type='get' id='1:roster' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq></body>

Response:
<body host="b2bdv-node" ack="7129396871" from="chat.myserver.com" xmpp:version="1.0" xmlns="http://jabber.org/protocol/httpbind" secure="true" xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams"><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/></body>

Request:
<body rid='7129396872' xmlns='http://jabber.org/protocol/httpbind' sid='eb62ed9b-df5a-49b9-8795-0fe081c71dd6'/>

Response:
<body host="b2bdv-node" ack="7129396872" from="chat.myserver.com" xmpp:version="1.0" xmlns="http://jabber.org/protocol/httpbind" secure="true" xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams"><iq to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result" id="1:roster"><query xmlns="jabber:iq:roster"><item name="user1@chat.myserver.com" jid="user1@chat.myserver.com" subscription="both"/></query></iq><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/></body>

Request:
<body rid='7129396873' xmlns='http://jabber.org/protocol/httpbind' sid='eb62ed9b-df5a-49b9-8795-0fe081c71dd6'><iq type='get' to='user1@chat.myserver.com' xmlns='jabber:client' id='2:sendIQ'><vCard xmlns='vcard-temp'/></iq><presence xmlns='jabber:client'/></body>

Response:
<body host="b2bdv-node" ack="7129396873" from="chat.myserver.com" xmpp:version="1.0" xmlns="http://jabber.org/protocol/httpbind" secure="true" xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams"><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/></body>

Request:
<body rid='7129396874' xmlns='http://jabber.org/protocol/httpbind' sid='eb62ed9b-df5a-49b9-8795-0fe081c71dd6'/>

Response:
<body host="b2bdv-node" ack="7129396874" from="chat.myserver.com" xmpp:version="1.0" xmlns="http://jabber.org/protocol/httpbind" secure="true" xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams"><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/><iq from="user2@chat.myserver.com" to="user2@chat.myserver.com/tigase-1" xmlns="jabber:client" type="result"/></body>

Also i tried with candy web client and all seems to work fine, and i cant connect with prebind easily and without this kind of problem. Do you think there is something wrong with tigase configuration?

Thank you.

jcbrand commented 9 years ago

Those last two responses with all the <iq type="result"> stanzas look weird.

What's weird is that there are so many of them per response, that they are from user2 to user2 (one JID without a resource) and that they are empty.

I don't know what's going on there.

I would suggest disabling some things. For example turn off message carbons and see what happens.

Also, perhaps one of the Tigase devs know what's happening. I haven't yet used Tigase.

rubsilva commented 9 years ago

I open an issue in tigase forums. What server do you use to work? Thank you.

jcbrand commented 9 years ago

I originally used ejabberd and now I use Prosody, which is easy install/configure and has a great community.

rubsilva commented 9 years ago

Well, it seems that there was a bug in tigase server, its already fixed, thanks for your support.

jcbrand commented 9 years ago

You're welcome, I'm glad your issue was resolved.