simple-smartsheet icon indicating copy to clipboard operation
simple-smartsheet copied to clipboard

aiohttp.client_exceptions.ServerDisconnectedError: None

Open dmfigol opened this issue 6 years ago • 2 comments

When the payload is incorrect, this is what I get from async call smartsheet.sheets.add_rows(sheet2.id, new_rows_group):

Traceback (most recent call last):
  File "scripts/move_rows.py", line 54, in <module>
    asyncio.run(main())
  File "/Users/dmfigol/.pyenv/versions/3.7.4/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/Users/dmfigol/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "scripts/move_rows.py", line 44, in main
    await smartsheet.sheets.add_rows(sheet2.id, new_rows_group)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/models/sheet.py", line 826, in add_rows
    result = await self.smartsheet._post(endpoint, data=data)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/smartsheet.py", line 245, in _post
    result = await self._request("POST", endpoint, data=data, result_obj=result_obj)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/smartsheet.py", line 205, in _request
    method=method, url=url, params=params, json=data
  File "<project-dir>/.venv/lib/python3.7/site-packages/aiohttp/client.py", line 1013, in __aenter__
    self._resp = await self._coro
  File "<project-dir>/.venv/lib/python3.7/site-packages/aiohttp/client.py", line 505, in _request
    await resp.start(conn)
  File "<project-dir>/.venv/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 848, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "<project-dir>/.venv/lib/python3.7/site-packages/aiohttp/streams.py", line 592, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None

However, sync version returns more complete exception:

Traceback (most recent call last):
  File "scripts/move_rows.py", line 42, in <module>
    asyncio.run(main())
  File "/Users/dmfigol/.pyenv/versions/3.7.4/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/Users/dmfigol/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "scripts/move_rows.py", line 36, in main
    smartsheet.sheets.add_rows(sheet2.id, new_rows_group)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/models/sheet.py", line 699, in add_rows
    result = self.smartsheet._post(endpoint, data=data)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/smartsheet.py", line 140, in _post
    result = self._request("POST", endpoint, data=data, result_obj=result_obj)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/smartsheet.py", line 102, in _request
    raise exceptions.SmartsheetHTTPError.from_response(response)
simple_smartsheet.exceptions.SmartsheetHTTPClientError: HTTP response code 400 - Error code 1062 - Invalid row location: You must use at least 1 location specifier.

dmfigol avatar Sep 12 '19 19:09 dmfigol

This can be fixed by sending a header Connection=close to the server. Found here: https://github.com/aio-libs/aiohttp/issues/850#issuecomment-471663047

Traceback (most recent call last):
  File "scripts/move_rows.py", line 54, in <module>
    asyncio.run(main())
  File "/Users/dmfigol/.pyenv/versions/3.7.4/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/Users/dmfigol/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "scripts/move_rows.py", line 44, in main
    await smartsheet.sheets.add_rows(sheet2.id, new_rows_group)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/models/sheet.py", line 826, in add_rows
    result = await self.smartsheet._post(endpoint, data=data)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/smartsheet.py", line 245, in _post
    result = await self._request("POST", endpoint, data=data, result_obj=result_obj)
  File "<project-dir>/.venv/lib/python3.7/site-packages/simple_smartsheet/smartsheet.py", line 208, in _request
    raise await exceptions.SmartsheetHTTPError.from_async_response(response)
simple_smartsheet.exceptions.SmartsheetHTTPClientError: HTTP response code 400 - Error code 1062 - Invalid row location: You must use at least 1 location specifier.

dmfigol avatar Sep 12 '19 19:09 dmfigol

Connection=close will disable keepalive which makes it a workaround, not a fix. This should be investigated deeper with debugs / exact information sent by client in sync and async cases. We don't get this behavior in sync case, why?

dmfigol avatar Jan 08 '20 19:01 dmfigol