Skip navigation
Currently Being Moderated

Flex app calling CF cfc to download file gets "Channel disconnected" fault

Oct 3, 2011 4:37 AM

Tags: #flex #coldfusion #file_download #channel_disconnected_fault

I am a newbie with ColdFusion and Flex. I am trying to implement file download/streaming functionality in my Flex 4.5 application and I am running ColdFusion 9 as my back end. More specifically, I have a component in my Flex app that displays a list of files - some of these files can be available for opening (or "previewing") via the client. I want the client to be able to click a button and download the file from the ColdFusion server, after the appropriate security checks are performed (also in ColdFusion). Right now I am just trying to get the basic download functionality to work with a very simple cfc. Here is the cfc code:

 

<cfcomponent displayname="Preview Document"

     output="false">

     <cffunction name="streamFile" access="remote" returntype="any">

          <cfargument name="filename" displayName="Filename" type="string" required="true" />

          <cfheader name="Content-Disposition" value="attachment;filename=#filename#" >

          <cfcontent type="application/unknown" file="c:\myserverpath\#filename#">

     </cffunction>

</cfcomponent>

 

When I try this via a cfm, it works fine (I get a File Download window where I can choose to either open or save the file). But when I try to use this in my Flex app, I get an error.

 

In my Flex app, I have a RemoteObject to access my cfc and a CallResponder:

 

<s:RemoteObject id="PreviewDocument"
   source="PreviewDocument"
   destination="ColdFusion"
   showBusyCursor="true"/>
 
  <s:CallResponder id="PreviewDocumentResult"
    fault="Alert.show('CallResponder PreviewDocumentResult: ' +
    event.fault.faultString + '\n' + event.fault.faultDetail)"
    result="PreviewDocumentResult_resultHandler(event)"/>

 

Then I created a button whose click even executes the following line:

 

PreviewDocumentResult.token = PreviewDocument.streamFile(

"myfile.pdf");

 

When I run my app, I get the following fault:

 

faultCode = "Client.Error.DeliveryInDoubt"

faultString = "Channel disconnected"

faultDetail = "Channel disconnected before an acknowledgement was received"

 

I have tried many different approaches and searched online for help with this fault, but I could not find any helpful clue to where I can start investigating this.

 

Can anyone help with why I am getting this fault?

 

Thanks in advance.

 
Replies
  • Currently Being Moderated
    Oct 3, 2011 6:06 AM   in reply to Godico77

    I am not completely sure, but aren't you supposed to <cfreturn/> somewhere

    within the function for flex to pick it up? Also, why not just send back the

    url to flex from coldfusion after the security handling and then just use

    navigateToUrl()  in flex?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 5:14 AM   in reply to Godico77

    Have you tried creating a super simple cfc that just returns a string just

    to see if it's configuration or the code that's failing?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 5:44 AM   in reply to Godico77

    Channel disconnected before an acknowledgement was received

    It means Flex isn't receiving a resp[onse back from ColdFusion. There could be 2 reasons for this.

     

    1) Your Application.cfc file implements onRequest(). If so, comment out the function. It is not allowed when you use Flash remoting.

    2)  The security checks you talk about involve page redirection, preventing ColdFusion from sending back a response. Test the effect of bypassing the security procedure.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 15, 2012 3:33 AM   in reply to Godico77

    sometimes I get a channel disconnected error the first time I calll something, then when I call it again from flex, it works? any ideas?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points