JSAPI map won't load layers until the page is refreshed.

4077
5
11-12-2012 09:03 AM
TimRourke
New Contributor
Client-side:
    ArcGIS JavaScript API version 2.5 - 2.7, local server installation
        jQuery
    Browsers: Internet Explorer (7, 8 and 9), Firefox and Chrome.


Server side:
    ASP.NET MVC 3 on Windows 2008 servers using IIS 7.5
Map services
    Operational layers (dynamic and feature layers) are on our ArcGIS Servers
    Basemap is the World Street Map layer from ArcGIS Online.


We have built some map applications to be consumed in pages built by other development teams.
When our map applications load the first time for a user (or after clearing the browser cache), one or more layers fails to load.


Our in-house map services depend on database connections that are severed by the firewall when they are maintained for too long. We have timed jobs to reset those map services, but when they're cut off it can take a couple of minutes for them to be available to users. That's not the issue I'm talking about here.


We added some JavaScript classes to check that the layers have loaded and retry if necessary, with a limit of five retries. After five failures to load, we pop up a message that tells the user one or more layers couldn't load and asks the user to refresh the page. After the refresh, the layers usually load, though not always.


The classes we added were modified from code found here at http://forums.esri.com/Thread.asp?c=158&f=2396&t=291261, but the other developers want the map to load first time, every time. I've been assuming this is a network issue - the code doesn't change, the map services don't change and the browser doesn't change - the only thing is a new call. Also, we changed to local installs of the JSAPI because we routinely get Dojo errors from the Esri CDN version not being found. Still, we need to get around this one.


A programmer on one of the other teams suggested the resources are not loading fast enough. Since the onLoad event is the only point I know of to determine when the API has loaded the layer, I've been checking it in debug. I even increased the number of retries and the timeout period. I found that if the layer didn't load the first time, it never will. But when I refresh the page, it loads the layers from the cache and it works. I clear the cache again, retry and it fails, then refresh and it works.


Has anyone else had a problem like this with their layers not loading?
0 Kudos
5 Replies
ShreyasVakil
Occasional Contributor II
Can you please post a simple reproducible case to do some testing/debugging?
0 Kudos
RoyJackson1
New Contributor III
How did you resolve this?
0 Kudos
TimRourke
New Contributor
How did you resolve this?


The only response I got was to ask for code to reproduce the problem. Since the code is the same as any code to load a FeatureLayer, the code won't make a difference. I'm pretty sure it's our environment, over which I have no control, so it's unlikely to be reproducible. I was looking more for some advice on how to get around the policies of a network and security setup that is unfriendly to map services and applications.

I didn't actually resolve the cause. Our application just runs through the list of layers to load and tries creating each one in turn. After all have been created, if any haven't loaded, we just go through it again up to five times. If any don't load then, we alert the user to refresh the page.
0 Kudos
DarinaTchountcheva
Occasional Contributor II
Tim and Roy,

It looks like you might be experiencing the "Sleepy services" issue, and it has nothing to do with JSAPI if you are using ArcGIS Server 9.3.x or 10.0.

This is more of a IIS behavior where default setting of an Application Pool on IIS is to recycle after 20 min of applications running under that pool being idle. Then when a user calls the services for a first time, it takes some time for the services to "wake up". And sometimes it requires a page refresh or a few for the services to load.

You can try to fix this by setting the Idle Time-out for the application pool to a higher number than 20 min (if there are times when the applications are not used for 4 hours for example, you can set the timeout to 240+ minutes). Also look at any other application pool recycling settings that might be causing the pool to shut down.

To make sure you modify the appropriate application pool, find out under what application pool are the ArcGIS\rest and ArcGIS\services applications running.

Please, consult your IIS administrator before you make the changes, as there are situations when they are not applicable (see articles above and search on your own more).

http://bradkingsley.com/iis7-application-pool-idle-time-out-settings/

http://technet.microsoft.com/en-us/library/cc771956(v=ws.10).aspx


Good Luck!
0 Kudos
NolanAlbarelli
New Contributor III

My app experiences this as well.  Almost every time i load the map 4 to 6 of my external services fail to laod.  I hit refresh and they all come into the web app, like clockwork.

0 Kudos