candy-chat / candy

JavaScript-based multi-user chat client for XMPP.
http://candy-chat.github.io/candy
MIT License
1.32k stars 370 forks source link

Can't join using Candy + Prosody #439

Open humitos opened 8 years ago

humitos commented 8 years ago

Hi,

I've been trying to make Candy + Prosody work for 2 weeks and I couldn't yet. I'm not sure if I have some issues in the configuration files or there is another problem.

I'm using (in a RaspberryPi):

When I hit chat.redlibre I can see the Candy form asking me for a nickname. So, I enter my nick and I click on "Login" but it still keep Connecting... and nothing happens...

My Candy configuration is:

Candy.Core.connect('chat.redlibre');

I went to the logs of prosody and I can see this:

Oct 18 13:52:46 socket  debug   server.lua: accepted new client connection from 127.0.0.1:55381 to 5280
Oct 18 13:52:46 mod_bosh        debug   BOSH body open (sid: %s)
Oct 18 13:52:46 bosh682cafb0-393f-4883-8b5c-ecd3218999a0        debug   BOSH session created for request from 127.0.0.1
Oct 18 13:52:46 mod_bosh        info    New BOSH session, assigned it sid '682cafb0-393f-4883-8b5c-ecd3218999a0'
Oct 18 13:52:46 httpserver      debug   Sending response to 2da758
Oct 18 13:52:46 httpserver      debug   Destroying request 2da758
Oct 18 13:52:46 httpserver      debug   Request has destroy callback
Oct 18 13:52:46 socket  debug   server.lua: closed client handler and removed socket from list
Oct 18 13:52:46 mod_bosh        debug   Session 682cafb0-393f-4883-8b5c-ecd3218999a0 has 0 out of 1 requests open
Oct 18 13:52:46 mod_bosh        debug   and there are 0 things in the send_buffer
Oct 18 13:52:46 socket  debug   server.lua: accepted new client connection from 127.0.0.1:55382 to 5280
Oct 18 13:52:46 mod_bosh        debug   BOSH body open (sid: 682cafb0-393f-4883-8b5c-ecd3218999a0)
Oct 18 13:52:46 mod_bosh        debug   Session 682cafb0-393f-4883-8b5c-ecd3218999a0 has 1 out of 1 requests open
Oct 18 13:52:46 mod_bosh        debug   and there are 0 things in the send_buffer
Oct 18 13:52:46 mod_bosh        debug   Have nothing to say, so leaving request unanswered for now
Oct 18 13:52:46 httpserver      debug   Request 3658c8 left open, on_destroy is function(mod_bosh.lua:81)

What I should do? Can you help me?

Let me know if you need more information from my side.

benlangfeld commented 8 years ago

You should show the content of the browser console with Candy's debug logging turned on.

humitos commented 8 years ago

@benlangfeld here you are:

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.min.js:1:0
[Init] Debugging enabled candy.min.js:1:1218
El uso de getPreventDefault() está desaprobado. Use en su lugar defaultPrevented. jquery.min.js:5:0
[Connection] Connecting candy.min.js:1:1218
[Strophe][DEBUG]: _throttledRequestHandler called with 1 requests candy.min.js:1:1545
[Strophe][DEBUG]: request id 1.0 posting candy.min.js:1:1545
[Strophe][DEBUG]: request id 1.0 state changed to 1 candy.min.js:1:1545
SENT: <body rid='1605559823' xmlns='http://jabber.org/protocol/httpbind' to='chat.redlibre' 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'/> candy.min.js:1:1218
[Strophe][DEBUG]: request id 1.1 state changed to 2 candy.min.js:1:1545
[Strophe][DEBUG]: request id 1.1 state changed to 3 candy.min.js:1:1545
[Strophe][DEBUG]: request id 1.1 state changed to 4 candy.min.js:1:1545
[Strophe][DEBUG]: removing request candy.min.js:1:1545
[Strophe][DEBUG]: _throttledRequestHandler called with 0 requests candy.min.js:1:1545
[Strophe][DEBUG]: request id 1 should now be removed candy.min.js:1:1545
[Strophe][DEBUG]: request id 1.1 got 200 candy.min.js:1:1545
[Strophe][INFO]: _connect_cb was called candy.min.js:1:1545
RECV: <body authid='8d922559-944b-4d95-b0f8-b6d27a39dba9' xmpp:version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns:xmpp='urn:xmpp:xbosh' inactivity='60' wait='60' polling='5' secure='true' hold='1' from='chat.redlibre' ver='1.6' sid='8d922559-944b-4d95-b0f8-b6d27a39dba9' requests='2' xmlns='http://jabber.org/protocol/httpbind'><stream:features/></body> candy.min.js:1:1218
[Strophe][DEBUG]: _throttledRequestHandler called with 1 requests candy.min.js:1:1545
[Strophe][DEBUG]: request id 2.0 posting candy.min.js:1:1545
[Strophe][DEBUG]: request id 2.0 state changed to 1 candy.min.js:1:1545
SENT: <body rid='1605559824' xmlns='http://jabber.org/protocol/httpbind' sid='8d922559-944b-4d95-b0f8-b6d27a39dba9'/> candy.min.js:1:1218

I hope it helps.

nogweii commented 8 years ago

I have nearly identical logs as well, with prosody 0.9.10 & Candy 2.2.0. Is there any news?

benlangfeld commented 8 years ago

No news yet. I haven't had a chance to reproduce and debug this. If anyone has a solution, though, I'd love to see it :)

philfry commented 8 years ago

Hi all,

candy doen't handle the 'terminate' type body so it just shows a "connecting..." and hangs. A possible cause for the bosh server to send a terminate may be that c2s_require_encryption is set but you're connecting to the bosh server in an unencrypted way. Also take a look at SASL mechanisms.

When using a proxy (e.g. apache mod_proxy) setting consider_websocket_secure is not sufficient. You will need to connect to the ssl port (5281) or set consider_bosh_secure.

TL;DR, for using ssl:

# prosody.lua:
modules_enabled = {
    "bosh";
};
c2s_require_encryption = true;
https_ssl = {
    key = "/path/to/prosody.key";
    certificate = "/path/to/prosody.pem";
}
https_ports = { 5281 }
https_interfaces = { "your ip addresses" }
# httpd proxy conf
SSLProxyEngine On
ProxyPass /http-bind "https://your.host.name:5281/http-bind" nocanon
ProxyPassReverse /http-bind "https://your.host.name:5281/http-bind"
ProxyPreserveHost On

regards

Phil