vdsm / virtual-dsm

Virtual DSM in a Docker container.
MIT License
2.53k stars 339 forks source link

Unable to send verification mail for 2FA #313

Closed Phorze closed 11 months ago

Phorze commented 1 year ago

Getting the following error:

Screenshot 2023-08-17 132327

But no sign of the cause of this. Any log file in /var/log i could be looking at?

kroese commented 1 year ago

In the control panel when you configure the SMTP server there is a button to send a Test email. Does it work when you send the test mail?

Phorze commented 1 year ago

Don't see a button, is suppose you mean the sender config in notifications?

Screenshot 2023-08-17 172022

kroese commented 1 year ago

Under 'Recipient profiles' the last button says: 'Send Test Email'. It will be enabled when you select a recipient.

Phorze commented 1 year ago

Test email was sent, but doesn't seem it was actually sent/delivered.

kroese commented 1 year ago

Then it cannot connect to your mailserver, so you need to check the settings for the SMTP server configuration.

Phorze commented 1 year ago

So is it actually working for others? I tried both Gmail and Outlook via the oauth method.. so seems pretty failsafe to me

kroese commented 1 year ago

It works for me.. with Sendgrid as SMTP server. Maybe Gmail refuses to send it because it does not recognize the from-address?

Phorze commented 1 year ago

Now tested using Sendgrid, smtp with api/password. No error but sendgrid is not detecting an email (also not receiving the email) I'm sure the problem is at my end but i don't know where to start. I am running behind a reverse proxy but surely that shouldnt be a problem for outgouing traffic. See startup log attached

startuplog.txt

Siyuanw commented 1 year ago

Potentially the same issue here... not able to send emails after setting up email notification. I set up an SMTP server and can confirm it doesn't receive any requests.

Not sure if it's related to synodsmnotify.

Getting some errors in /var/log/messages about it.

2023-09-09T19:47:08+01:00 dsm synodsmnotify[26954]: stringdb.cpp:173 Failed to query ImproperShutdownFrequently sql:SELECT source FROM 'category' WHERE tag='ImproperShutdownFrequently' LIMIT 1 2023-09-09T19:47:08+01:00 dsm synodsmnotify[26954]: synodsmnotify.cpp:919 Fail to send notify ImproperShutdownFrequently to @administrators

kroese commented 11 months ago

For me the SMTP notifications are working succesfully. So we must figure out what the difference is between our configurations.

Siyuanw commented 11 months ago

thank you @kroese.

Are you using bridge networking or macvlan+dhcp?

bridge. Not sure if it's a bug: the vdsm has no internet access in bridge mode as it cannot sync NTP and cannot check system update. However, it CAN download package.

Not sure why I cannot use macvlan+dhcp. Getting below error

RTNETLINK answers: Operation not supported
❯ ERROR: Cannot create macvtap interface. Please make sure the network type is 'macvlan' and not 'ipvlan',
❯ ERROR: and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN
❯ Starting Virtual DSM for Docker v4.19...

Have you configured a valid serialnumber for DSM or are you using the default (00000000000)?

I was using default. And I tried to apply the valid vdsm serial but no luck with sending notification.

Are you logged in to your Synology account or not?

yes in host. no in guest (vdsm).

Can you post your compose-file here so I can look at the settings?

here you go. I commented network part as getting error when running macvlan.

version: "3"
services:
    dsm:
        image: kroese/virtual-dsm:latest
        environment:
            DISK_SIZE: "16G"
            ALLOCATE: "N"
            CPU_CORES: "2"
            RAM_SIZE: "1024M"
            HOST_SERIAL: "_MASKED_"
            GUEST_SERIAL: "_MASKED_"
            # DHCP: "Y"
        devices:
            - /dev/kvm
            - /dev/vhost-net
        device_cgroup_rules:
            - 'c *:* rwm'
        cap_add:
            - NET_ADMIN
        ports:
            - 5000:5000
        volumes:
            - storage:/storage
        restart: on-failure
        stop_grace_period: 1m
        # networks:
            # vdsm:
                # ipv4_address: 192.168.1.100
volumes:
    storage:
networks:
    vdsm:
        external: true

also, here's the command when creating docker network

sudo docker network create -d macvlan \
    --subnet=192.168.1.0/24 \
    --gateway=192.168.1.1 \
    --ip-range=192.168.1.100/28 \
    -o parent=ovs_eth0 vdsm
kroese commented 11 months ago

bridge. Not sure if it's a bug: the vdsm has no internet access in bridge mode as it cannot sync NTP and cannot check system update. However, it CAN download package.

I have seen this problem a couple of times before. It does also happen when the time is incorrect on the system, so my guess was that it cannot verify the SSL certificate of the update server when the time is wrong, but it can download packages because they are downloaded without SSL connection.

But since you say you cannot even sync the time, it must be something else that is causing this, because to make a connection to 'time.google.com' does not require SSL.

My next guess would be some kind of DNS problem. Maybe the downloadcenter uses some fixed IP's but the update-server needs DNS to resolve its address. Is there anything special about your DNS configuration? Do you use the one from your ISP or some custom ones?

Can you try to add this to your composefile:

   dns:
      - 1.1.1.1
      - 1.0.0.1

And see if it makes a difference?

Not sure why I cannot use macvlan+dhcp.

Is your host OS a Synology DSM? Because I believe it does not support macvtap because its running a very old kernel (4.x). But you should be able to use macvlan without DHCP=Y.

Last question: if you go in control-panel to notifications, and click "send a test notification". Does the test mail arrive? Because I cannot be sure that I receive every kind of notification myself, but I am very sure that at least the test-notification always works for me.

Also see if removing /dev/vhost-net from your composefile makes a difference. It offloads networking to the kernel for better performance, but its not strictly required, so maybe your network issues will be gone without it.

Siyuanw commented 11 months ago

Really appreciate your response.

The network issue is resolved. I never thought it was a DNS issue. Although it doesn't work when adding dns config to docker-compose, I set DNS in the vDSM and it worked.

Yes I'm running it on a Synology DSM. It worked when I remove DHCP=Y. Now the vDSM is running on its own ip.


However, the notification still doesn't work. I've tried to run vDSM on another machine with macvlan+dhcp, and still no luck.

I have a SMTP server configured in local network. Which doesn't receive anything. I'm able to login with Gmail. But still not getting anything.

Here is a very interesting thing that I found: When configuring it in Control Panel -> Notification, I don't see any request in SMTP server. And nothing happens when "Send a test notification". But when setting it in user's profile (personal -> Email Delivery), I do see SMTP server receives a request that verifies the SMTP server "Client sent: EHLO 192.168.1.xxx". However, I'm not sure how to trigger an email in this way.

kroese commented 11 months ago

Do you mean by nothing happens that you also do not get the message:

"A test email has been sent. If you do not receive an email, please make sure the settings are correct." ?

Can you see if anything shows up in the Log Center after sending the test-message?

Siyuanw commented 11 months ago

Yes. I do see this message "A test email has been sent. If you do not receive an email, please make sure the settings are correct."

Nothing specific in log center about the notification/email.

xrh0905 commented 11 months ago

Hello. It seems like this is a bug of Synology. In recent update it mentions that "Fixed error of notfication not being send" I'll try it out and report back if things back to normal.

kroese commented 11 months ago

There is a new update available now (7.2.1-69057). You can go to Control Panel > Update & Restore to install it. Maybe it fixes the notification problem for the people affected here?

Siyuanw commented 11 months ago

Thank you @kroese and @xrh0905 for sharing the info! Yes it worked after upgrading to the latest version.

Just put the link here in case anyone need: https://global.synologydownload.com/download/DSM/release/7.2.1/69057-1/DSM_VirtualDSM_69057.pat