ArcGISTiledMapServiceLayer not rendering after sleep

1233
1
Jump to solution
06-27-2016 02:51 PM
MarcusHakansson
New Contributor II

I'm using ArcGIS Runtime SDK for .NET (10.2.7) to develop an App in Visual Studio 2013.

I've installed the App in a device (tablet) wich uses Windows 8.1 as its OS. When i start the App the map looks fine but if I dont use the device for about an hour or more and then log in (nessesary becouse device is in sleepmode) the map doesnt show. All I see is blank tiles and the map does not reload. So I have to shut down the App and open it again to see the map.

I've appended the project.

Reply
0 Kudos
1 Solution

Accepted Solutions
MarcusHakansson
New Contributor II

This problem have now been solved thanks to Esris support team.

Il explain it if someone else has the same problem:

With Fiddler I could see that server responded "498 Invalid Token" when request were sent for new tiles after beeing in sleppmode for more then an hour.

This was becouse the token were generated in Arcgis Server with a lifespan of one hour.

This was fixed by replacing

IdentityManager.Current.GenerateCredentialAsync(ONLINE_BASEMAP_TOKEN_URL, USERNAME, PASSWORD);
cred.ExpirationDate = DateTime.Now.AddDays(14);
IdentityManager.Current.TokenValidity = 14 * 24 * 60;

with

GenerateTokenOptions options = new GenerateTokenOptions();

options.TokenValidity = 60 * 24 * 14;

options.TokenAuthenticationType = TokenAuthenticationType.ArcGISToken;

    var cred = await IdentityManager.Current.GenerateCredentialAsync(ONLINE_BASEMAP_TOKEN_URL, USERNAME, PASSWORD, options);

Another solution could have been to change the lifespan of the token on the server

View solution in original post

Reply
0 Kudos
1 Reply
MarcusHakansson
New Contributor II

This problem have now been solved thanks to Esris support team.

Il explain it if someone else has the same problem:

With Fiddler I could see that server responded "498 Invalid Token" when request were sent for new tiles after beeing in sleppmode for more then an hour.

This was becouse the token were generated in Arcgis Server with a lifespan of one hour.

This was fixed by replacing

IdentityManager.Current.GenerateCredentialAsync(ONLINE_BASEMAP_TOKEN_URL, USERNAME, PASSWORD);
cred.ExpirationDate = DateTime.Now.AddDays(14);
IdentityManager.Current.TokenValidity = 14 * 24 * 60;

with

GenerateTokenOptions options = new GenerateTokenOptions();

options.TokenValidity = 60 * 24 * 14;

options.TokenAuthenticationType = TokenAuthenticationType.ArcGISToken;

    var cred = await IdentityManager.Current.GenerateCredentialAsync(ONLINE_BASEMAP_TOKEN_URL, USERNAME, PASSWORD, options);

Another solution could have been to change the lifespan of the token on the server

View solution in original post

Reply
0 Kudos