Just to add a bit to this issue... when you have auto-sync="true", LC DS should automatically disconnect and reconnect but unfortunately that was not working automatically in 2.5.1. Here's a little program I wrote to automatically connect if the app is started when the server is not available and automatically reconnect if you get disconnected. This might help resolve your problem.
<?xml version="1.0" encoding="iso-8859-1"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="appReady()" width="700" height="900"> <mx:DataService id="dataService" destination="SQLPerson"/> <mx:ArrayCollection id="testCollection"/> <mx:Script> <![CDATA[ import mx.events.*; import mx.data.*; import mx.data.events.*; private var timer:Timer = null; public function appReady():void { dataService.fill(testCollection); dataService.addEventListener("propertyChange", connectedListener); dataService.addEventListener(DataServiceFaultEvent.FAULT, faultListener); } private function faultListener(event:DataServiceFaultEvent):void { trace("fault event occurred"); } private function connectedListener(event:PropertyChangeEvent):void { if (event.property == "connected") { if (!event.newValue) { trace("disconnected"); startTimer(); } else { trace("reconnected"); if (timer != null) { timer.stop(); timer = null; } } } } private function startTimer():void { if (timer == null) { timer = new Timer(2000); timer.addEventListener(TimerEvent.TIMER, reconnectHandler); timer.start(); } } private function reconnectHandler(event:TimerEvent):void { if (!dataService.connected) { dataService.disconnect(); dataService.connect(); // NOTE: you might also want to put your fill/getItem calls here // to be sure you get fresh copies of the data after you reconnect. // If that is awkward, you can set the option // <reconnect fetch="INSTANCE" /> in your data-management-config.xml for // each destination so that when a reconnect occurs, we refill all data. } } ]]> </mx:Script> <mx:TraceTarget/> <mx:DataGrid id="testGrid" percentHeight="100" percentWidth="100" dataProvider="{testCollection}" editable="true"/> <mx:Label text="{dataService.connected ? 'connected' : 'not connected'}"/> </mx:Application> ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Seth Hodgson Sent: Thursday, January 24, 2008 9:15 PM To: [email protected] Subject: RE: [flexcoders] Re: LCDS Paging error and connection management in DataServices. Advice? Oh, and in regard to AMF polling and your connected state, this channel issues poll requests over HTTP on an interval. If your server is unreachable, the next poll request that is sent will fail, triggering the channel to move to a disconnected state. If you enable client logging (<mx:TraceTarget> and a debug player) you should be able to see log entries for the channel issuing poll requests and when one of these fails, an entry stating that the channel has stopped polling. Best, Seth ________________________________________ From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On Behalf Of Kevin Sent: Thursday, January 24, 2008 5:35 PM To: [email protected] <mailto:flexcoders%40yahoogroups.com> Subject: [flexcoders] Re: LCDS Paging error and connection management in DataServices. Advice? Thanks. Do you know if the connected property works in amf-polling as well? As an experiment I tried to disconnect my wireless connection while the app was running and the connected property didn't change. However, using RTMP it works fine. Also, is there a way to distinguish a disconnect from when the server is down or has restarted? In those cases, it seems I need to for my users to relaunch the application rather than just try to reconnect to the channel. I would love to see some sample code (if there is any out there) from anyone who has handled all these connection/disconnection issues in DMS. It seems like there is a fair amount to try to keep track of with these type of connections vs a simple asynchronous call. Thanks, Kevin --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Seth Hodgson" <[EMAIL PROTECTED]> wrote: > > Hi Kevin, > > DataService exposes a bindable 'connected' property that lets you know whether its underlying channel to the server is up or not. If it's not up, DataService will attempt to reconnect indefinitely. You should watch the 'connected' property and let the user know when they've lost connectivity, as well as when connectivity is regained. > > DataService also provides a disconnect() method that can be used to shut down the instance, and will also stop any further automatic reconnect attempts. > > Hope that helps, > Seth > ________________________________________ > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On Behalf Of Kevin > Sent: Thursday, January 24, 2008 9:07 AM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: LCDS Paging error and connection management in DataServices. Advice? > > I'll add to this post, how do you check the connected status if you > are using amf-polling?? > > If I turn off my internet connection while working, I get tons of > errors when trying to navigate the app since things are all of a > sudden not loading in via paging... > > I am not sure the best way to handle this. > > - Kevin > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Kevin" <lists@> wrote: > > > > I am trying to handle a situation where my user are getting > > temporarily disconnected from my web app and then proceeding to > > continue enter info thinking that it is being saved simply because it > > is still working in actionscript. (of course nothing is getting > > persisted to the database at this point). This problem seems very > > unique to data management since we are not making explicit calls to > > the database and instead it is being handled by DataServices. > > > > I have tried to set up an Alert warning and a status indicator so that > > they know when then are connected again, however, sometimes I am > > getting the follow error when the web app is reconnected (see below). > > Admittedly this usually happen when there is a server restart > > (although is there a way to check for this?), but I am still wondering > > how best to manage my apps connection since I am not doing explicit > > asynchronous calls to the database? > > > > Thanks for the help. - Kevin > > > > > > > > [RPC Fault faultString="Pages for sequence id 209 have expired in > > destination relationships." faultCode="Server.Processing" > > faultDetail="null"] > > at > > > mx.data::ConcreteDataService/http://www.adobe.com/2006/flex/mx/internal: :dispatchFaultEvent <http://www.adobe.com/2006/flex/mx/internal::dispatchFaultEvent> ()[C:\depot\flex\branches\enterprise_bridgeman_final_hotfixes\frameworks \mx\data\ConcreteDataService.as:2112] > > at > > > DataListRequestResponder/fault()[C:\depot\flex\branches\enterprise_bridg eman_final_hotfixes\frameworks\mx\data\ConcreteDataService.as:6022] > > at > > > mx.rpc::AsyncRequest/fault()[E:\dev\flex\sdk\frameworks\projects\rpc\src \mx\rpc\AsyncRequest.as:103] > > at > > > NetConnectionMessageResponder/statusHandler()[E:\dev\flex\sdk\frameworks \projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:531] > > at > > > mx.messaging::MessageResponder/status()[E:\dev\flex\sdk\frameworks\proje cts\rpc\src\mx\messaging\MessageResponder.as:222] > > >

