home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.59k stars 29.91k forks source link

Synology DSM integration timeout after success login du to storage listing #105019

Closed binou-31 closed 9 months ago

binou-31 commented 9 months ago

The problem

Hi,

I'm facing an issue during the DSM integration with home assistant. I already configured this integration properly one time and lost the configuration. that's not working now. After a long troubleshooting, i tested directly with the python library py-synologydsm-api and the default code exemple from https://pypi.org/project/py-synologydsm-api/

I figure out that the login password works properly and stuck after the storage listing. I have only one storage with lot of directory and file from my security camera, nothing more.

Perhaps we can improve the integration to not stuck the enrollment process into home assistant and perform after in async mode the storage discovery ? or have an option to override the timeout on the first login/password integration in home assistant.

In this situation, i can't finish the integration du to timeout.

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

core-2023.11.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

synology_dsm

Link to integration documentation on our website

No response

Diagnostics information

homeassistant:/config# python3 testsyno.py
Creating Valid API
/config/testsyno.py:8: DeprecationWarning: verify_ssl is deprecated, use ssl=False instead
  connector=aiohttp.TCPConnector(verify_ssl=False)
=== Information ===
Model:           DS418
RAM:             2048 MB
Serial number:   17A0PHN248000
Temperature:     40 °C
Temp. warning:   False
Uptime:          27647
Full DSM version:DSM 7.2.1-69057 Update 3
--
=== Utilisation ===
CPU Load:        5 %
Memory Use:      32 %
Net Up:          27799
Net Down:        511825
--
=== Storage ===

        Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/synology_dsm/synology_dsm.py", line 347, in _execute_request
    return await response.json(content_type=content_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1099, in json
    await self.read()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1037, in read
    self._body = await self.content.read()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 375, in read
    block = await self.readany()
            ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 397, in readany
    await self._wait("readany")
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 303, in _wait
    with self._timer:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/testsyno.py", line 61, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/config/testsyno.py", line 10, in main
    await do(session)
  File "/config/testsyno.py", line 36, in do
    await api.storage.update()
  File "/usr/local/lib/python3.11/site-packages/synology_dsm/api/storage/storage.py", line 13, in update
    raw_data = await self._dsm.get(self.API_KEY, "load_info")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synology_dsm/synology_dsm.py", line 207, in get
    return await self._request("GET", api, method, params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synology_dsm/synology_dsm.py", line 282, in _request
    response = await self._execute_request(request_method, url, params, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synology_dsm/synology_dsm.py", line 358, in _execute_request
    raise SynologyDSMRequestException(exp) from exp
synology_dsm.exceptions.SynologyDSMRequestException: {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'TimeoutError'}

Example YAML snippet

No response

Anything in the logs that might be useful for us?

with debugmode=True, this stuck after this request without knowing why ..

=== Storage ===
DEBUG: API: SYNO.Storage.CGI.Storage
DEBUG: Request Method: GET
DEBUG: Request url: https://192.168.20.218:5001/webapi/entry.cgi?api=SYNO.Storage.CGI.Storage&version=1&method=load_info&action=load_info&_sid=*********&SynoToken=*********
DEBUG: Response status_code: 200
DEBUG: Response headers: {'Server': 'nginx', 'Date': 'Mon, 04 Dec 2023 19:58:34 GMT', 'Content-Type': 'application/json; charset="UTF-8"', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=20', 'Vary': 'Accept-Encoding', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Encoding': 'gzip'}

Additional information

Only one local storage from Surveillance station lot of files an directories from 90 days of cameras records no file sharing local dedicated hassio account created with allowed access to surveillance station. all sharing files services deactivated (smb, nfs, afp, rsync) even all files deleted from Surveillance storage, the listing is still stuck. i deleted my files for nothing :'( http2 and http compression activated on the synology

home-assistant[bot] commented 9 months ago

Hey there @hacf-fr, @quentame, @mib1185, mind taking a look at this issue as it has been labeled with an integration (synology_dsm) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `synology_dsm` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign synology_dsm` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


synology_dsm documentation synology_dsm source (message by IssueLinks)

binou-31 commented 9 months ago

MTU configured to 1500 fixed on my network interface solved the issue.