Select to view content in your preferred language

Dynamic Legends: Missing Images after Idle/Long Application Duration

1905
15
05-04-2010 07:31 AM
IrfanClemson
Frequent Contributor
Hi,
I have dynamic legends working fine for the most part, as per Robert's code from:
http://forums.esri.com/thread.asp?c=158&f=2421&t=299116&mc=137
However, I notice that if the user's session in the SFV application goes, say, over 20-30 minutes the images for the legends are not being returned by the server. Please see the attached screen cap. Using Service Capture I can see 404 errors pointing toward various .png files. I think these .png files are dynamically created by the ArcGIS Server's Map Service and their names change upon refreshing the browser (upon which the legends start working again -most- of the time).
I suspect there is some kind of 'flush' of data or some kind of 'recycling' of Services going on. May be something like:
http://forums.arcgis.com/threads/3177-Services-Fail-To-Load-in-SFV-Unless-Recently-Recycled-in-ArcGI...
Obviously, we can't have user's session limited to less than half hour or so and we can't expect them to refresh their browser window to get rid of the problem. I kind of remember our ArcGIS Server admin--who is also quite new to the management aspect of the server--telling me that he has some kind of 'flush' going on periodically. I will check with him but I want to get your input on this first.
Thanks!
Meengla
Tags (2)
0 Kudos
15 Replies
RobertScheitlin__GISP
MVP Emeritus
Meengla,

   This was always an issue, but I fixed it a while ago so here is the new code for the LegendData.mxml file. it uses a loader that loads the bytes from the image url instead of just having the image reference the url that might have been deleted on the server.

<?xml version="1.0" encoding="utf-8"?>
<!--
////////////////////////////////////////////////////////////////////////////////
//
// Copyright © 2008 ESRI
//
// All rights reserved under the copyright laws of the United States.
// You may freely redistribute and use this software, with or
// without modification, provided you include the original copyright
// and use restrictions.  See use restrictions in the file:
// <install location>/FlexViewer/License.txt
//
////////////////////////////////////////////////////////////////////////////////
-->
<mx:HBox xmlns:mx  ="http://www.adobe.com/2006/mxml" 
   xmlns:flash  ="flash.filters.*" 
   width   ="95%" 
   minHeight  ="22" 
   backgroundAlpha ="1" 
   paddingLeft  ="3" 
   paddingRight ="3" 
   verticalAlign ="middle" backgroundColor="#FFFFFF">
 
 <mx:Script>
  <![CDATA[
  
   import flash.display.Loader;
  
   [Bindable]
   private var recicon:String = "";
   
   [Bindable]
   private var title:String;
   
   private var _infoData:Object;
   
   private var _loader:Loader; 
   
   public function get infoData():Object
   {
    return _infoData;
   }
   
   public function set infoData(value:Object):void
   {
    _infoData = value;
    
    _loader  = new Loader();
    _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event):void
     { 
      recIcon.source = e.currentTarget.content;
      recIcon.visible = true;
      recIcon.includeInLayout = true;
     }
    );
    _loader.load(new URLRequest(encodeURI(infoData.icon))); 
    title = infoData.title;
   }
   
  ]]>
 </mx:Script>
 
 <mx:Image id="recIcon" visible="false" includeInLayout="false" />
 <mx:VBox verticalGap="0" width="90%">
  <mx:Text selectable="false" fontWeight="bold" text="{title}" width="90%"/>
 </mx:VBox>
</mx:HBox>
0 Kudos
IrfanClemson
Frequent Contributor
Robert,
That did the trick! Thanks!
Meengla
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Meengla,

   I have begun to work on a new one for ArcGIS Server 10 and the New Flex web API Viewer that will be so much simpler to get working (no web service), and will be an independent widget (not part of the TOC widget). It will still be completely dynamic (updating when layers are turned on and off and scale ranges will be honored). Plans are to make the config xml file that has a list of map services and layers of those map services that you want excluded from the legend. Legend swatches will draw using Flex 4 Graphic Primitives and not require images from the server (in most cases), so it will also require Flex 4 and at least Flash Player 10, which will be required by the New Flex web API Viewer anyway.
0 Kudos
IrfanClemson
Frequent Contributor
Robert,
I have advised my institution to start migrating toward ArcGIS Server 10 and Flex API 2 and Flex 4. That process is going to take time.
But, meanwhile, I notice that even using the modified legenddata.mxml per your code above is not working for me: I still see 404 errors related to .png graphics of the legends icons.
Here is what my Service Capture tells me:
At 9:00 AM,
GET /arcgisoutput/_ags_leg22f08466ff714f55889e54d097763b30.png
server returned HTTP/1.1 200 OK
At 9:30 AM,
GET /arcgisoutput/_ags_leg22f08466ff714f55889e54d097763b30.png HTTP/1.1
server returned HTTP/1.1 404 Not Found and my Flex debugger pops up:
Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.
I don't think loading the bytes is going to help when there is no image existing on the server to load?

I have spent too much time on this to let it fail; I have managed to program the dynamic legends in the SearchWidget.mxml file as well.

Any idea about what is happening? As I said above, there is some kind of 'recycling' of data going on ArcGIS Server; please note that the dynamic legends SOAP calls always return the layer names--just the images/icons of legends are being lost after extended user sessions.

If you don't mind I can send you a link to the deployed web app; I don't have the authority to share that link openly yet.
Thanks!
Meengla
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Meengla,

   Well I thought that I had that issue resolved using the loader... I guess it's back to the drawing board on this one. For now you can fix the issue by setting the directory cleanup to 1 hour on your ArcGISOutput folder in ArcGIS Server Manager. So go to server manager and click GIS Server button on the left and then Server Directories, once there verify that the chow combobox says Output Directories and then click the Edit (little pencil icon), look at the Maximum File Age: and set to 60 minute(s)
0 Kudos
ShawnKraft
Occasional Contributor
Robert I downloaded and installed the 39609.zip file you had in another post.  It was for allowing for a dynamic legend.  I have a couple questions.  In the readme.txt in the zip file it says to "on line 402 change http://yourserver/restLegend/restLegend.asmx?wsdl to your server".  What file is line 402 in?  Also, I create my projects on my local machine and then move them to my production server to deploy.  Do I run the setup.exe contained in the zip file on my local machine or the server?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shawn,

       The setup needs to be run on the server. The line number might not be 402 but it will be in the LiveMapsWidget.mxml.
0 Kudos
IrfanClemson
Frequent Contributor
Meengla,

   Well I thought that I had that issue resolved using the loader... I guess it's back to the drawing board on this one. For now you can fix the issue by setting the directory cleanup to 1 hour on your ArcGISOutput folder in ArcGIS Server Manager. So go to server manager and click GIS Server button on the left and then Server Directories, once there verify that the chow combobox says Output Directories and then click the Edit (little pencil icon), look at the Maximum File Age: and set to 60 minute(s)


Robert,
Sorry for being late; it did take some time having access to the Server...
Increasing to 60 minutes has definitely improved the situation. Still, if  a user's session exceeds 60 minutes then the problem happens. But I am okay for now.
Thanks!
0 Kudos
RuiboHan
Emerging Contributor
Hi, Robert,

I wonder if you are still following this thread, but I have the same problem about missing swatches.
Here is my situation:
I am using 39609MapLegendWidget.zip from this link http://forums.esri.com/thread.asp?c=158&f=2421&t=299116&mc=137, it has been working perfectly on my local server (I run arcgis server 9.3.1 and flex viewer 1.3 on the same pc). However, when I migrate the arcgis server to another server, and I access this server through IP address (don't know if it has fully qualified name), the missing swatches problems came up.

I test the http://localhost/restLegend/restLegend.asmx on the server, and the returned url for the swatches is something like http://wllbgis(server's name)/arcgisoutput/_ags_leg89d320faf9224f2fb2b37589f246d1d0.png. I tested this on my local pc with http://205.189.23.11(IP of the server)/arcgisoutput/_ags_leg012f6eca60594fa7b354e08b233baec6.png, and it is accessible through ie. But the swatches are missing from flex viewer. If I run the flex viewer on the server end, the swatches can be displayed perfectly.

I am just guessing that if the result of http://localhost/restLegend/restLegend.asmx would return the url with ip not the server's name, it would be able to load the legend through the interest. So any suggestions? Thanks for your help in advance.

Ruibo
0 Kudos