powered by Jive Software

Openfire and Strophe on Android. Device sends same request twice

Hi all,

I am developing chat feature for some android app. I am in stuck. I debugged problem for 2 days and need help.

Server: openfire 3.7, tried on ubuntu and standard Amazon EC2 linux.

Client: based on strophe.js, use http-bind.

What happens

Case1. Server and android are in local network. I run html page on android browser. Everything works like a charm.

Case2. Client connects through internet. For some reason, android browser sends identical request twice, after 60 seconds. Server says “item not found” and terminate the session. It happens both on android emulator and on real device.

Case3. Same HTML/JS on desktop - FF, Chrome - works through internet

Case4. Instead of openfire, install PROSODY. Android works!

I have tcpdump log from android side. It shows that android indeed sends identical requests (same RID). I analyzed it in wireshark and found that there are 2 tcp streams. There are options “follow TCP stream” and “hide TCP stream” in wireshark. First stream starts from user auth and ends with stanza X. Second stream starts from same stanza X.

I see on openfire server:

Tue Mar 15 18:39:05 KRAT 2011: HTTP RECV(b92b25c):

Tue Mar 15 18:40:05 KRAT 2011: HTTP SENT(b92b25c):

Tue Mar 15 **18:40:05 **KRAT 2011: HTTP RECV(b92b25c):

Tue Mar 15 18:40:05 KRAT 2011: HTTP ERR(b92b25c): terminate, item-not-found.

Tue Mar 15 18:40:05 KRAT 2011: HTTP SENT(b92b25c):

Tue Mar 15 18:40:06 KRAT 2011: HTTP RECV(b92b25c):

Brielfy. Desktop bvrowsers works, android works in local net, android works with prosody but not with openfire through internet.

Tested with 2 servers and 2 clients in 2 different cities. This is not firewall issue.

I think this is about socket options in openfire.

Thanx for any ideas.

I can send tcpdump file for analisis.

More info.

I forgot to say that standard Strophe example ‘echobot’ also doesn’t work.

I did tcpdump of Strophe conversation with Prosody. There is big difference. Every request/response opens new TCP stream. Conversation with openfire reuse TCP stream. I see that authentication challenge/responses are going in one stream, as well as stanza. When it closes, next TCP stream starts with last sent packet. Thus, server sees duplicate request.

Maybe it is possible to change openfire config (or source) so it closes TCP stream after sending response to client?

Continue updating.

I tested ejabberd server. It behaves similar to openfire - client and server reuse TCP stream, so several request/responses are going inside one TCP session. Hovewer, Strophe.js works with ejabberd. Tcpdump shows that ejabberd simply sends empty body when it receives second request with same RID. I patched openfire so it also sends empty body instead of termination of the session. And - wow! - strophe.js works!

Obviously, there is something wrong. As i said, I tested it with 2 servers in different data-centers and with 2 clients in different cities. This is not firewall issue.

I would like to know any ideas about the problem. How it can be, why android resends latest request? Strophe.hs does not send it. It comes from magic world.

Hi Alexey

Thanks for sharing the experience.

Would you share which part of the openfire you patched?

We are suspecting the “magic world” you mentioned is the Android browser.

Let me test with Strophe on iOS to see if it exhibits the same behavior.