BlazeDS Flex Error: Channel disconnected before an acknowledgement was received.

I developed an application with Flex as UI and Java as backend. BlazeDS as the integration between the two and the application was deployed on Tomcat 7 server. 
The initial release was on simple http so there were no issues until recently when we were asked to move all the applications over to SSL for security reasons.


The SSL configuration on Tomcat is fairly easy and i was able to access my Flex application on HTTPS with no issues. However there was a strange issue that was occurring everytime the application was left idle for some time.
Upon catching the error message it was:
faultString:'Channel disconnected' 
faultDetail:'Channel disconnected before an acknowledgement was received'.


I tried adding few additional configuration parameters to services-config.xml such as:
 <login-after-disconnect>true</login-after-disconnect> 


But it didnt work.
Finally this is the resolution which took care of this channel disconnect issue permanently:


1. Add the following channel definition to services-config.xml



<channel-definition id = "my-mixed-amf" class = "mx.messaging.channels.SecureAMFChannel">
<endpoint url = "https://{server.name}:{server.port}/{context.root}/messagebroker/amfmixed"
 class = "flex.messaging.endpoints.AMFEndpoint" />
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
<connect-timeout-seconds>1000</connect-timeout-seconds>
</properties>
</channel-definition>


2. Update the remoting-config.xml and proxy-config.xml to reflect this new channel.
3. Rebuild the SWF application in Flash Builder IDE and export the release build to Tomcat.
4. Phew!!! The application now works like a charm with no channel disconnect errors anymore even after a long idle time.


Cause:
The channel class uses HTTPS to hit the firewall/proxy, and the endpoint URL must point at the 
firewall/proxy. Because SSL is handled in the middle, you want the endpoint class used by BlazeDS to be the 
insecure AMFEndpoint and your firewall/proxy must hand back requests to the HTTP port of the BlazeDS server, not the HTTPS port.
Ref: http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=lcconfig_5.html

Comments

David W said…
I think I need this also, but, what are the changes you have to make to remoting-config-xml and proxy-config.xml?

Should the existing secure channel be removed?

Thanks!
Raj said…
Sorry for the late response. Add the following element to both remoting-config.xml and proxy-config.xml:



Hope its not too late. Thanks.
Anonymous said…
Thank you very much for this post! incredibly useful! Also, can you please re-answer David W's question? I have the same questions, and your appnswer appears to just be bank!
Here arethe questions again:

"I think I need this also, but, what are the changes you have to make to remoting-config-xml and proxy-config.xml?

Should the existing secure channel be removed?"

Thank you!
Raj said…
Please add the following :

1. remoting-config.xml :


<default-channels>
<channel ref="my-mixed-amf"/>
<!--<channel ref="my-amf"/> -->
</default-channels>"




2. proxy-config.xml:


"<default-channels>
<channel ref="my-mixed-amf"/>
<!-- <channel ref="my-amf"/> -->
</default-channels>"



You can remove the secure channel as it is not being referenced anywhere else.

Hope this helps.

Thanks.

Popular posts from this blog

Load data from CSV into HIVE table using HUE browser

Setting property 'keystoreFile' did not find a matching property. No Certificate file specified or invalid file format

Gitlab change project visibility from private to internal