views:

486

answers:

3

Hi everybody,

I have a problem using Flex with BlazeDS on a Tomcat 5.5 through a Proxy (Apache). I already searched for it but didn't find answers which solved my problem. I hope you guys can help me out. :-)

Our scenario is the following:

Flex-App using BlazeDS to communicate with our Dataservice on a Tomcat 5.5. The Webapp is balze enabled and the services config contains channel definitions like the following:

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://xxx.xxx.xxx.xxx:8180/myDataService/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint">
</channel-definition>

I set the Flex Server Root URL to http://xxx.xxx.xxx.xxx:8180/myDataService (Context Root: /myDataService) and compile my flex application against this services-config.

After that I deploy my flex application and my dataservice on a server with some ip address xxx.xxx.xxx.xxx. The two applications are available after that using http://xxx.xxx.xxx.xxx:8180/myFlexApp or for the dataservice: http://xxx.xxx.xxx.xxx:8180/myDataservice The tomcat is listening on port 8180.

If I open my flex application using the URL with the ip address everything is working fine. My application is receiving data perfectly.

Ok. Everything fine so far.

Now I want to use a proxy server (via apache http server) to hide the ip and use a domain name.

I do the following changes to my services-config:

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://mydomain.com/data/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint">    
</channel-definition>

I set the Flex Server Root URL to http://mydomain.com/data (Context Root /data) and compile my flex application against this services-config.

I deploy the applications again on the same tomcat as before.

Now I create an entry in the sites-available (sites-enabled) folder of my apache directory (etc/apache2/sites-available/) called mydomain.com I create a Virtual Host with ServerName www.mydomain.com and ServerAlias mydomain.com. I also add the neccessary rules in the Proxy block and the other stuff neccessary for the virtual host definition. The following ProxyPass/ProxyPassReverse entries are contained in this file:

ProxyPass /flexApp http://xxx.xxx.xxx.xxx:8180/myFlexApp
ProxyPassReverse /flexApp http://xxx.xxx.xxx.xxx:8180/myFlexApp

ProxyPass /data http://89.19.229.148:8180/myDataservice
ProxyPassReverse /data http://89.19.229.148:80/myDataservice

After that I can open the flex Application with http://www.mydomain.com/flexApp in the browser and it loads. But an error message is thrown when it tries to contact the dataservice using blazeds. I even can't open the URL http://mydomain.com/data/messagebroker/amf. A 404 Error is displayed. Before - using the ip address - a blank page was displayed. The weird thing is, that the non-blaze Servlets are working fine. e.G. I can open http://mydomain.com/data/myServlet and it works. Only Blaze doesn't work.

Do you have any ideas why this problem occurs and how i may solve it. Thanks a lot in advance. You're really helping me out!!!

Henrik

A: 

Both BlazeDS and the Flex app are using the URL in the channel-definition's endpoint. But the URLs actually need to be different. BlazeDS needs to use the myDataservice/messagebroker/amf URL while the Flex app needs to use the data/messagebroker/amf URL. So you can either make both URLs the same, ie. myDataservice instead of data. Or you can manually set the channel information in the Flex app instead of having it read the services-config file.

James Ward
A: 

I'm having the same problem. Did you found a solution to solve this?

jubolani
A: 

I'm using AJP for the request redirection:

// enable mod_proxy_ajp
a2enmod proxy_ajp

The proxy configuration looks like this:

ProxyPass /flexApp/messagebroker/ ajp://localhost:8009/flexApp/messagebroker/
splash