Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too much data for declared Content-Length #947

Closed
RS-Y opened this issue Jul 5, 2024 · 2 comments
Closed

Too much data for declared Content-Length #947

RS-Y opened this issue Jul 5, 2024 · 2 comments

Comments

@RS-Y
Copy link

RS-Y commented Jul 5, 2024

When I use mosaicjson to request a service, the request is very slow when minzoom is small, and When mosaicjson bounds are exceeded it results in a 204 error. Below is the detailed error information

Traceback (most recent call last):
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
    return await self.app(scope, receive, send)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/middleware/base.py", line 189, in __call__
    with collapse_excgroups():
  File "/etc/miniconda3/envs/titiler/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/_utils.py", line 93, in collapse_excgroups
    raise exc
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/responses.py", line 261, in wrap
    await func()
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/middleware/base.py", line 217, in stream_response
    return await super().stream_response(send)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/responses.py", line 253, in stream_response
    await send({"type": "http.response.body", "body": chunk, "more_body": True})
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/starlette/middleware/errors.py", line 161, in _send
    await send(message)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 493, in send
    output = self.conn.send(event=h11.Data(data=data))
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/h11/_connection.py", line 512, in send
    data_list = self.send_with_data_passthrough(event)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/h11/_connection.py", line 545, in send_with_data_passthrough
    writer(event, data_list.append)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/h11/_writers.py", line 65, in __call__
    self.send_data(event.data, write)
  File "/etc/miniconda3/envs/titiler/lib/python3.10/site-packages/h11/_writers.py", line 91, in send_data
    raise LocalProtocolError("Too much data for declared Content-Length")
h11._util.LocalProtocolError: Too much data for declared Content-Length

The mosaicjson used is as follows:
{"mosaicjson":"0.0.3","version":"1.0.0","minzoom":17,"maxzoom":22,"quadkey_zoom":17,"bounds":[113.26320648193358,22.845014155559195,113.28612327575685,22.86099101151058],"center":[113.27466487884521,22.853002583534888,17],"tiles":{"13212222120030321":["E:\workspace\1\cog\1\0\1_0_b1_b2_b3_tile_0_0_cog.tif"],"13212222120030330":["E:\workspace\1\cog\1\0\1_0_b1_b2_b3_tile_0_0_cog.tif"],"13212222120030331":["E:\workspace\1\cog\1\0\1_0_b1_b2_b3_tile_0_0_cog.tif"],"13212222120031220":["E:\workspace\1\cog\1\0\1_0_b1_b2_b3_tile_0_0_cog.tif"],"13212222120031221":["E:\workspace\1\cog\1\0\1_0_b1_b2_b3_tile_0_0_cog.tif","E:\workspace\1\cog\1\0\1_0_b1_b2_b3_tile_1_0_cog.tif"]...........................}}

@RS-Y RS-Y added the bug Something isn't working label Jul 5, 2024
@vincentsarago vincentsarago removed the bug Something isn't working label Jul 5, 2024
@RS-Y
Copy link
Author

RS-Y commented Jul 5, 2024

Especially when minzoom is < 10,The service response is quite slow,Then my entire service process will be occupied and stuck

@vincentsarago
Copy link
Member

Dear @RS-Y, While we encourage people raising issues, we ask for user to provide more information in order to be able to help you as much as we can.

You're talking about 2 different issues:

When mosaicjson bounds are exceeded it results in a 204 error

This was solved in 0.18.1, https://github.com/developmentseed/titiler/blob/main/CHANGES.md#0181-2024-04-12

When I use mosaicjson to request a service, the request is very slow when minzoom is small

We do need to make a better documentation for this. You can read #291 first.

The issue, is that when requesting low zoom level, the tiler will have to open/read numerous files. Some files might represent maybe only 1pixel on the final tile... meaning that it's almost useless.

We usually recommend to set fetch tiles starting for the mosaic minzoom. We also have a settings to return 400 is the zoom requested is not between min/max zoom

strict_zoom = str(os.getenv("MOSAIC_STRICT_ZOOM", False)).lower() in [
"true",
"yes",
]
tms = self.supported_tms.get(tileMatrixSetId)
with rasterio.Env(**env):
with self.reader(
src_path,
tms=tms,
reader=self.dataset_reader,
reader_options={**reader_params},
**backend_params,
) as src_dst:
if strict_zoom and (z < src_dst.minzoom or z > src_dst.maxzoom):
raise HTTPException(
400,
f"Invalid ZOOM level {z}. Should be between {src_dst.minzoom} and {src_dst.maxzoom}",
)

@developmentseed developmentseed locked and limited conversation to collaborators Jul 5, 2024
@vincentsarago vincentsarago converted this issue into discussion #949 Jul 5, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants