BOSH with Air gives service-unavailable (503) / Error #2032

It seems that XIFF / XMPPBOSHConnection is not really compatible with Air. I am finally getting my Flash application to work great with BOSH but we have an AIR version of this application and I can’t have it work properly.

I managed to get connected on my eJabberd server but most of time I’m disconnected right after. XIFF is throwing a XIFFErrorEvent with Error Code 503 (service-unavailable) and if I trace the event.text property of the native IOErrorEvent, it displays a #2032 Flex/AIR error as if the URLLoader of the XMPPBOSHConnection class could not access to my BOSH URL (which is working great for the Flash version and even for the AIR version because I manage to be logged in right before it bugs… )

I found on the net some people who have issues with Flex and URLLoader when polling a given URL too often.

But I can’t really well define where the problem is…

Have you tried polling less frequently?

Can you post a minimal code to reproduce this problem

The problem is that it’s not a polling issue. I mean, if I poll less frequently, I don’t think it will change something because the problem does not occur when polling but when sending normal requests such as presence and so on.

But now I know that it is a proxy issue. I still don’t know why it occurs only with AIR and not with Flash but it seems that AIR randomly receives a 502 Proxy Error from Apache…

More informations… I can’t really say if it’s an Apache issue or what because I receive randomly 404 errors regarding my BOSH URL… Quite strange to receive randomly 200, 404 or 502 HTTP error codes when using URLLoader…

And what is very interesting is that I have strange eJabberd logs when I get these error codes… So I think there is an undetermined issue with XIFF and/or eJabberd with AIR. Maybe AIR, as it is executed locally and not in a browser, cannot properly manage HTTP sessions, BOSH or whatever ?

Here are some logs when I get the 502 error :

=INFO REPORT==== 2010-01-27 15:16:07 ===

D(<0.4397.0>:ejabberd_http_bind:342) : state.rid/cur rid: 521818/521817

=INFO REPORT==== 2010-01-27 15:16:07 ===

D(<0.4397.0>:ejabberd_http_bind:409) : REPEATING 521817

=INFO REPORT==== 2010-01-27 15:16:07 ===

D(<0.4397.0>:ejabberd_http_bind:663) : terminate: deleting session 7b5474e63fd03ecd357c71e6f4c7932220e70643

=ERROR REPORT==== 2010-01-27 15:16:07 ===

** State machine <0.4397.0> terminating

** Last message in was {‘$gen_sync_all_state_event’,

{<0.4405.0>,#Ref<0.0.0.85672>},

{http_put,521817,

[{“sid”,

“7b5474e63fd03ecd357c71e6f4c7932220e70643”},

{“rid”,“521817”},

{“xmlns”,

                                   "[http://jabber.org/protocol/httpbind](http://jabber.org/protocol/httpbind)"}],

[[60,

“iq”,

[[32,“type”,61,39,“get”,39],

(…)

** When State == loop

** Data == {state,“7b5474e63fd03ecd357c71e6f4c7932220e70643”,

521818,

,

,

,

{<0.4398.0>,ok},

<0.4398.0>,

0,

undefined,

undefined,

1264601767132291,

#Ref<0.0.0.85667>,

0,

[{hbr,521818,

,

,

[[,

60,

“presence”,

[[32,

“from”,

(…)

** Reason for termination =

** {{badmatch,},

[{ejabberd_http_bind,handle_sync_event,4},

{gen_fsm,handle_msg,7},

{proc_lib,init_p,5}]}

=INFO REPORT==== 2010-01-27 15:16:07 ===

I(<0.4399.0>:ejabberd_c2s:1299) : ({socket_state,ejabberd_http_bind,{http_bind,<0.4397.0>},<0.4398.0>}) Close session for XXX

And some logs when I get the error 404 :

=INFO REPORT==== 2010-01-27 15:14:48 ===

D(<0.4392.0>:ejabberd_http_bind:691) : no session associated with sid:

“d94a61c049b71b3d3a824bcd4a7bf22e8d3745a6”

Still don’t know what’s happening…

So. It seems that (for a most part) the issue is due to Apache. Each time my AIR application fails with a 502 error, I have these two lines in Apache logs :

proxy: error reading status line from remote server 127.0.0.1, referer: app:/XXX.swf

proxy: Error reading from remote server returned by /http_bind, referer: app:/XXX.swf

And here is the configuration that I have in Apache concerning my eJabberd server and proxy (it’s an example where I remove the real domain name) :

NameVirtualHost myejabberd.domain.com:80

ServerName myejabberd.domain.com

RewriteEngine On

 RewriteRule ^/http_bind [http://127.0.0.1:5280/http_bind/](http://127.0.0.1:5280/http_bind/) [P]
 RewriteRule ^/crossdomain.xml [http://radiomee.ovmee.net/crossdomain.xml](http://radiomee.ovmee.net/crossdomain.xml) [P]
 <Proxy [http://127.0.0.1](http://127.0.0.1)>

Order Deny,Allow

Deny from all

Allow from all

I think your Apache configuration file is unnecessarily complicated. Are you using Apache on *nix (highly recommended)?

If so, then enable the proxy and proxy_http mods. My proxy.conf looks like the following:

#turning ProxyRequests on and allowing proxying from all may allow

#spammers to use your proxy to send email.

ProxyRequests Off

<Proxy *>

AddDefaultCharset off

Order allow,deny

Allow from all

Enable/disable the handling of HTTP/1.1 “Via:” headers.

(“Full” adds the server version; “Block” removes all outgoing Via: headers)

Set to one of: Off | On | Full | Block

    ProxyPass /http-bind/ [http://192.168.1.95:5280/http-bind/](http://192.168.1.95:5280/http-bind/)

    ProxyPass /tigase-http-bind/ [http://192.168.1.101:5280/](http://192.168.1.101:5280/)

    ProxyPass /ejabberd-http-bind/ [http://192.168.1.100:5280/http-bind/](http://192.168.1.100:5280/http-bind/)

I hardly understand your configuration because as far as I’m concerned my eJabberd server is on the same machine but has its own domain name. If I put the configuration directly in the proxy.conf, which domain names / ports will take the configuration into consideration ?

But if I try your configuration with mine, that is to say by writing it in a virtual host ejabberserver.domain.com:80 it still doesn’t work…

And when I try to handle the proxy.conf, it doesn’t work either…

Argh

Aha, I realize I gave no explanation.

Assuming your modules are enabled correctly and you know where to put the proxy.conf file in your installation (it should be symlinked to the equivalent file in the mods-available folder, just like all you *.load files), then the only lines you have to change are the ProxyPass lines.

I have 3 XMPP server types (OpenFire, Tigase, and ejabberd) running on VMs so I have 3 lines with different BOSH paths that get proxied to the different servers. Since you have 1 server, and your proxy is running on the same local host, your ProxyPass line can look like the following:

ProxyPass /<bosh_path>/ http://localhost:<server_bosh_port>/<server_bosh_path>

Where bosh_path is the path part of the BOSH URL your client will use, and server_bosh_port and server_bosh_path are the configuration for your particular server’s BOSH setup.

Hope that makes sense!

Karthik

Yes the problem was not in the configuration but in the version of eJabberd.