• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

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.

TOPICS
Flash integration

Views

5.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2011 Oct 04, 2011

Copy link to clipboard

Copied

Thanks for your reply. I added the cfreturn tag to my cfc but still get the error.

I see the point of your suggestion of sending back the URL to flex, but in reality we really want to have all the connections go through our ColdFusion server.

Is it  possible to accomplish this, or must I go through flex in this case?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2011 Oct 04, 2011

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2011 Oct 04, 2011

Copy link to clipboard

Copied

@sir_teddy, thanks for your reply again.

Yes I have created a simple cfc that returns a string successfully (in fact I had used the same cfc and basically just commented out the cfcontent and cfheader tags, and returned the name of the file being requested in the cfreturn tag). When I un-comment the cfcontent tag from the code, the error comes back.

So I am really at a loss here...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2011 Oct 04, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2011 Oct 04, 2011

Copy link to clipboard

Copied

@BKBK, thanks for replying.

1) I am not creating an Application.cfc file, nor do I have one in my CFC path.

2) I have not implemented the security checks yet, this is something I will do *after* I get this basic functionality to work...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 15, 2012 Aug 15, 2012

Copy link to clipboard

Copied

LATEST

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation