[SOLVED] NotificationEmailSender Error

I have…

  • [X] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [X] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

Under the consumers, the NotificationEmailSender shows that a bug is happening and provides the following error:

System.InvalidOperationException: An asynchronous call is already in progress. It must be completed or canceled before you can call this method.
at System.Net.Mail.SmtpClient.SendAsync(MailMessage message, Object userToken)
at System.Net.Mail.SmtpClient.SendMailAsync(MailMessage message)
at System.Net.Mail.SmtpClient.SendMailAsync(String from, String recipients, String subject, String body)
at Squidex.Infrastructure.Email.SmtpEmailSender.SendAsync(String recipient, String subject, String body) in /src/src/Squidex.Infrastructure/Email/SmtpEmailSender.cs:line 39
at Squidex.Domain.Apps.Entities.History.Notifications.NotificationEmailSender.SendEmailAsync(String emailSubj, String emailBody, IUser assigner, IUser assignee, String appName) in /src/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailSender.cs:line 81
at Squidex.Domain.Apps.Entities.History.Notifications.NotificationEmailEventConsumer.On(Envelope`1 event) in /src/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs:line 110
at Squidex.Infrastructure.EventSourcing.Grains.EventConsumerGrain.DispatchConsumerAsync(Envelope`1 event) in /src/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs:line 247
at Squidex.Infrastructure.EventSourcing.Grains.EventConsumerGrain.<>c__DisplayClass12_0.<<OnEventAsync>b__0>d.MoveNext() in /src/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs:line 91
--- End of stack trace from previous location where exception was thrown ---
at Squidex.Infrastructure.EventSourcing.Grains.EventConsumerGrain.DoAndUpdateStateAsync(Func`1 action, String caller) in /src/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs:line 200

Expected behavior

Async call shouldn’t be a problem because you are creating a new SMTPclient every time, but for some reason it thinks you’re using the same one.

Minimal reproduction of the problem

This is a fresh install after adding some content and users.

Environment

  • [ ] Self hosted with docker
  • [X] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 4.0.3

Browser:
N/A

Thanks for the bug report. Have you verified that you are sending emails in parallel? Perhaps it is just a timeout that gets a strange error message.

I’m not sure we’re sending emails at all. Unless the system sends emails for certain events, then we are not. I have not configured a rule to send any emails.

The only things we have done in the system are create users, create apps, and create content/schemas.

I have found another place, where the Smtp Client was not used properly and fixed that.

1 Like