Skip to content

Expose RetryClient in NetworkTileProvider initialisation#1297

Closed
MichalTorma wants to merge 6 commits intofleaflet:masterfrom
MichalTorma:master
Closed

Expose RetryClient in NetworkTileProvider initialisation#1297
MichalTorma wants to merge 6 commits intofleaflet:masterfrom
MichalTorma:master

Conversation

@MichalTorma
Copy link
Copy Markdown

This pull request adds optional parameter RetryClient for NetworkTileProvider. I made this fork to scratch my own itch with some stubborn tile servers that are either too slow or don't follow the standard conventions. Some servers require longer cooldown between the requests therefore more than 3 retries are needed (as was the default in NetworkImageWithRetry).

Copy link
Copy Markdown
Contributor

@ibrierley ibrierley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, out of interest, what would be a good example code that someone would use as the optional RetryClient ?

@MichalTorma
Copy link
Copy Markdown
Author

So, out of interest, what would be a good example code that someone would use as the optional RetryClient ?

Hi there,
Here is an example of layer definition that I needed for one open server that replies 200 every-time you ask for something, but response either contains png as one would expect, or content-type is different and error message (too many requests) is inside the response body. (don't as me why :D - It's Norwegian national cartography server...). I also needed to increase the number of retries because it is a bit sluggish...

        TileLayerOptions(
            tileProvider: NetworkTileProvider(
                retryClient: RetryClient(
              Client(),
              retries: 10,
              when: (p0) => p0.headers['content-type'] != 'image/png',
            )),
            wmsOptions: WMSTileLayerOptions(
                baseUrl: 'https://openwms.statkart.no/skwms1/wms.topo4?',
                layers: ['topo4_WMS'],
                version: '1.3.0',
                format: 'image/png',
                crs: const Epsg3857(),
                transparent: false)),

@JaffaKetchup
Copy link
Copy Markdown
Member

This will conflict with #1294, but it's not too much of an issue, so I'm happy for it to be merged ahead.

@JaffaKetchup
Copy link
Copy Markdown
Member

@MichalTorma Hi there,

I've had to make some unexpected changes to #1294, which includes the changes that PR made. You can see the commit which did this: ad2adb6.

As a result, I'm going to close this PR. Many thanks for your contribution, it's greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants