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.88k stars 30.11k forks source link

Cannot connect anymore to Synology DSM #110848

Closed archipita closed 1 month ago

archipita commented 7 months ago

The problem

Since some time, HA cannot connect anymore to the Synology DSM. I have tried with a dedicated user with 2FA enabled and another user with 2FA disabled, but the connection is not established in either cases. In the first case HA says that the 2FA is not successful (although when inserting the code it says OK), in the second case it says that the 2FA is missing, with the result that I am blocked. I am using a DS1821+ with DSM 7.2.1-69057 Update 1.

What version of Home Assistant Core has the issue?

core-2024.2.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Synology DSM

Link to integration documentation on our website

https://www.home-assistant.io/integrations/synology_dsm/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

home-assistant - 20240218.log

Additional information

No response

home-assistant[bot] commented 7 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)

fcollonval commented 7 months ago

I was having the same issue. But restarting the server fixed it. So I did not get the chance to see if the error was exactly the same.

archipita commented 7 months ago

Thank you for the suggestion. Actually I did that already, but did not help.

I made many more tests with the 2FA enabled and I cannot find a way to make it working again. Something must have changed in the SW.

In the meantime I have found a possible workaround that is not good (for security reasons!), but it is the only one working right now: I have created a completely new user, with admin rights, but without any access to any app nor directory and I am connecting with this user from the HA to the DS using the external IP address of the DS. I tried as well the direct connection within the intranet, but it did not work.

I would prefer to have no admin users without a 2FA enabled on my DS, but this is the only way working right now. Any suggestion/help on solving the issue with the 2FA activated is very appreciated.

davmc123 commented 7 months ago

I am having a similar issue to the others here. I was having issues with the my Synology integration as it kept disconnecting and wasn't reconnecting without a home assistant restart. I deleted it and I am not able to add it again and I get the error message "Failed to connect" after a few seconds. It get the same error whether or not 2FA is on and it has persisted through a restart.

2024-03-03 22:18:48.080 ERROR (MainThread) [homeassistant.components.synology_dsm.config_flow] {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'TimeoutError'}

The NAS I am having issues with is a DS1520+ running DSM 7.2.1-69057 Update 4

I have another Synology DS918+ NAS that the integration seems to be working fine with running a slightly older DSM 7.1.1-42962 Update 6.

Anyone have any suggestions on additional log info I could provide that might help diagnose this issue?

zuerom commented 7 months ago

I am having a similar issue to the others here. I was having issues with the my Synology integration as it kept disconnecting and wasn't reconnecting without a home assistant restart. I deleted it and I am not able to add it again and I get the error message "Failed to connect" after a few seconds. It get the same error whether or not 2FA is on and it has persisted through a restart.

2024-03-03 22:18:48.080 ERROR (MainThread) [homeassistant.components.synology_dsm.config_flow] {'api': None, 'code': -1, 'reason': 'Unknown', 'details': 'TimeoutError'}

The NAS I am having issues with is a DS1520+ running DSM 7.2.1-69057 Update 4

I have another Synology DS918+ NAS that the integration seems to be working fine with running a slightly older DSM 7.1.1-42962 Update 6.

Anyone have any suggestions on additional log info I could provide that might help diagnose this issue?

Same here with DS1512+ Firmware: DSM 6.2.4-25556 Update 7 (latest available release because it's deprecated)

Flintr commented 7 months ago

Same exact story here. DS1512+ running DSM 6.2.4-25556. Latest available DSM version.

bezibaerchen commented 6 months ago

Check the usage of your Synology, especially when it comes to disk operations. Found this thread as I was experiencing it myself, however, I was "slightly" saturating my DS918+ Once it settled, the integration came back to life.

smarthomefamilyverrips commented 6 months ago

Check the usage of your Synology, especially when it comes to disk operations. Found this thread as I was experiencing it myself, however, I was "slightly" saturating my DS918+ Once it settled, the integration came back to life.

@bezibaerchen you mean your system was not in healthy state? I now have a failing disk and since then also have problems with the integration being able to setup.... most likely related to bad system state of NAS??? What you think?

This is error i get:

Unexpected error fetching 192.168.0.117 SynologyDSMCentralUpdateCoordinator data: The config entry 192.168.0.117 (synology_dsm) with entry_id 72025f29a77296ccf62cabf3d6e58746 cannot be unloaded because it is not in a recoverable state (ConfigEntryState.SETUP_IN_PROGRESS)

briodan commented 6 months ago

running into the same/similar issue, the integration is stuck in Initializing status and the log has the "cannot be unloaded because it is not in a recoverable state" message. if I restart HA, the integration comes up correctly only to eventually break again.

The only issue I had on the system was a space available warning alert on one of the volumes.

mib1185 commented 6 months ago

@archipita i've checked the code, your log and the API documentation of synology adn can't find any issues there about 2FA login procedure.

Just to avoid any quirks with old/orphaned configuration entries in HA, please

  1. remove all Synology DSM integrations
  2. enable debug logging
    logger:
    default: info
    logs:
      homeassistant.components.synology_dsm: debug
  3. restart HA
  4. add the NAS again with 2FA again
  5. and provide the full home-assistant.log

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

fnordson commented 5 months ago

I had this happen to me several times in the recent days until I realized that the NAS was offline when I restarted Home Assistant.
It just didn't catch up afterward when the NAS was online again. Had to restart HA.

archipita commented 5 months ago

@archipita i've checked the code, your log and the API documentation of synology adn can't find any issues there about 2FA login procedure.

@fnordson thank you for the feedback and the effort spent! Unfortunately, I am traveling a lot in these days and won't be able to make some proper tests soon. I will try as soon as possible.

In the meantime, as mentioned above, I am using the connection without 2FA and this is working fine since some weeks. Also after upgrading both the HA and the DS.

DoWenzl94 commented 5 months ago

Same Issue here

mib1185 commented 5 months ago

"Same Issue here" doesn't really help, please use the +1 reaction on the initial post, thx 👍 Sure, any further information, which might be helpful to identify the issue, are highly welcome.

mib1185 commented 5 months ago

Unfortunately, I am traveling a lot in these days and won't be able to make some proper tests soon. I will try as soon as possible.

@archipita ok, meanwhile i'll tag this as "waiting for reply"

mdaryabe commented 4 months ago

I had the same problem I believe. What I ended up doing is changing the timeout period from 15 sec to 90 sec and that actually helped. seems like the older DS models are kinda slowing down and the initiation process times up before it establish a connection

mib1185 commented 4 months ago

please re-try with HA 2024.5.2 and set the timeout to 30s, thx

archipita commented 4 months ago

@mib1185 @fnordson sorry for the very long delay of my reply, but the last period has been pretty busy. I have made again some tests and when I try to connect with the 'homeassistant' user that has the 2FA active the RECONFIGURE process says it is OK, but then the connection fails. Here are the logs as requested, with only the DSM debug enabled... home-assistant_synology_dsm_2024-06-01T13-47-47.539Z.log There is not a lot though. For the time being I will continue to use the connection without the 2FA enabled. I have created an 'ha' user without access to anything, so the risk of having issues is reduced.

Daniel-dev22 commented 2 months ago

I'm running into this same issue.

I'm on ha core 2024.7.1

Except when I go into Synology and check login logs I can see the homeassistant user is successful for 1fa and 2fa. So I don't understand why I keep getting this error. I tried rebooting Synology, restarting home assistant neither works. Removing the integration, re-adding, reconfiguring and all are the same result.

Config entry 'synology.domain.com' for synology_dsm integration could not authenticate: reason: Two-step authentication required for account: homeassistant
cogentcoder commented 2 months ago

I'm having the same issue. I have DS116 and DS220+. Both were working fine till few days ago (till 18th July) but now only DS116 works and DS220+ has error as described above with HA Core 2024.7.1. I have Samba backup addon with different username on Synology DS220+ is able to login and save backup on Synology DS220+ as well as MariaDB running on DS220+ via SSH tunnel is working fine. I don't remember if DS220+ is upgraded and that has changed something.

cogentcoder commented 2 months ago

My problem is solved. I was using a managed switch between Synology DS220+ and the router and has enabled static link aggregation on the switch. I think, that combination has messed up the Synology router setup settings. So in Synology menu, it could not pass router setup test. DS116 has no dual ethernet port and so no link aggregation and therefore, I had no issue with it in HA. I removed static link aggregation from switch, then in Synology menu I let Synology configure again which it did successfully. Then I reloaded the Synology DSM integration in HA, that has fixed the issue for me.

Daniel-dev22 commented 2 months ago

My problem is solved. I was using a managed switch between Synology DS220+ and the router and has enabled static link aggregation on the switch. I think, that combination has messed up the Synology router setup settings. So in Synology menu, it could not pass router setup test. DS116 has no dual ethernet port and so no link aggregation and therefore, I had no issue with it in HA. I removed static link aggregation from switch, then in Synology menu I let Synology configure again which it did successfully. Then I reloaded the Synology DSM integration in HA, that has fixed the issue for me.

Not sure this helps for those with 2fa enabled we are seeing something different.

stemapplications commented 2 months ago

I was messing around with my DS1512+ and the link aggregation. Thought it might have something to do with the piss poor speed of the Active Backup for Business. Changed it from LACP to static on the switch and Synology but to no avail. Changed it back to LACP on both and haven't been able to connect since! Can't even see a MAC address (arp or bootp). But really haven't had much time since to play with it.

wneessen commented 2 months ago

I had the same issue with the 2FA. For me it solved the issue by switching from my local DNS name for the NAS to the IP. Maybe this works for someone else too

stemapplications commented 2 months ago

This is so strange. The Power light is flashing blue, the LAN port lights on the front are flashing green but there is no activity on the lights on the actual RJ45 ports with the cables plugged in. Synology Assistant can't see the Synology 1512+, my managed switch can't see the MAC IDs, arp command can't see the MAC IDs nor can Rockwill Bootip or Phoenix IPAssign.

Tried all this while coonect to my LAN and also connect direct to my computer. Nothing.

Holding the reset button for 4 seconds does not give a beep.

How the heck can you get into a Synology if the Ethernet Ports aren't working? Is this thing bricked?

cogentcoder commented 2 months ago

@stemapplications if you are using a managed switch between your router and synology and has messed up with dynamic link aggregation in synology then also check your managed switch and setup accordingly because link aggregation in synology require that you enable it in the switch or router as well. If disabled in synology then disable it in switch/router. If that doesn't solve the issue then connect synology directly with your computer or laptop and try to connect by setting up assigning a domain ip in your computer or laptop.

Daniel-dev22 commented 1 month ago

Here's my debug logs from home assistant of Synology dsm attempting to connect.

What's odd is that on Synology DSM I can see successful logins from the homeassistant user.

User [homeassistant] from [192.168.15.1] has successfully passed the first authentication of 2FA via [password]

synology_log.txt

I see types': [{'type': 'otp'}]}}, 'success': False}

@mib1185 Does it not like the otp passed? I can login to the UI of Synology as the homeassistant user with 2fa just fine. Now I wonder if this is the true issue? Something wrong with how otp is being passed/used in the integration resulting in a 403?

stemapplications commented 1 month ago

Contacted support to help diagnose. Turns out my DS1512+ was toast. Would not boot, ethernet ports dead. She was only 13 years old. RIP.

Picked up a DS1621+, took the drives out of my DS1618+ and moved them into the new NAS then put the DS1512+ drives into the older DS1618+ and have my backup NAS working again now.

mib1185 commented 1 month ago

I've tested now with a virtual DSM based on DSM 7.2.1-69057 Update 5 and 2FA enabled (I use authy on my android phone)

now going to investigate, the 2nd test result

mib1185 commented 1 month ago

found the cause of the issue in the py-synologydsm-api lib - will create a fix later

Daniel-dev22 commented 1 month ago

found the cause of the issue in the py-synologydsm-api lib - will create a fix later

Awesome glad you were able to reproduce this issue.

Daniel-dev22 commented 1 month ago

found the cause of the issue in the py-synologydsm-api lib - will create a fix later

Unfortunately I'm running 2024.8.2 and this doesn't fix the issue when setting up the integration for the first time. I can't say if it fixes it for an already setup integration but I'm seeing the same issue when setting up a new Synology DSM integration

Seeing the same logs as before

2024-08-16 15:43:02.295 DEBUG (MainThread) [synology_dsm.synology_dsm] Successful returned data
2024-08-16 15:43:02.295 DEBUG (MainThread) [synology_dsm.synology_dsm] RESPONSE: {'error': {'code': 403, 'errors': {'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIyRkEiLCJleHAiOjE3MjM4Mzc2ODIsImlhdCI6MTcyMzgzNzM4Miwic3ViIjoiaG9tZWFzc2lzdGFudCJ9.DEo_HrkSyae4NAVFTdjGn7-v_xF17UZi8LbgkiV6k-M', 'types': [{'type': 'otp'}]}}, 'success': False}
2024-08-16 15:43:02.295 WARNING (MainThread) [homeassistant.config_entries] Config entry 'synology.domain.com' for synology_dsm integration could not authenticate: reason: Two-step authentication required for account: homeassistant
mib1185 commented 1 month ago

@Daniel-dev22 please open a new issue report and put as much as possible of information in it - especial please provide full debug logs (see below) and details about your Nas (model und DSM version) , thx 👍


enable debug logging, restart HA and provide the home-assistant.log To do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.synology_dsm: debug
    synology_dsm: debug
Daniel-dev22 commented 1 month ago

@Daniel-dev22 please open a new issue report and put as much as possible of information in it - especial please provide full debug logs (see below) and details about your Nas (model und DSM version) , thx 👍

enable debug logging, restart HA and provide the home-assistant.log To do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.synology_dsm: debug
    synology_dsm: debug

Opened https://github.com/home-assistant/core/issues/124105