Sends emails from time to time, even if emails are sent

This problem left me at a standstill. This question may need to be ported to Server Fault, but there is a programming component, so I decided that I would start. In addition, our infrastructure team passionately believes that everything is in order from the end, but that does not always mean anything.

In any case, I have a simple GET-POST-Redirect action that sends two separate letters using the Postal nuget package before redirecting to the success page - a fairly simple piece of material. The action isync, and I use await email.SendAsync()from the Postal API.

When the form is submitted, the first email arrives in my inbox instantly, but the code is in this line await email.SendAsync()for 15-20 seconds before it moves to the next line (confirmed in the debugger). Then he sends a second email, which instantly enters my mailbox again, and again the code hangs on this line, regardless of the successful sending, for 15-20 seconds before moving on to the redirected line. During production, this delay after sending emails, combined for the two emails, causes a connection to reset before you can send a response to the redirect. Of course, I could just drag the page, but this does not really fix the problem, as the user still ends the minute delay before receiving a response.

I also tried sending emails synchronously only with email.Send(), but the same behavior is happening. I looked at the source for Postal, and although some custom shells around SMTPClient are emailed to send asynchronous email, there is practically nothing there except the standard old C # email sending with the synchronous method Send.

It is also not connected with the server on which the site is running, because I can see the same behavior both in production and in debugging locally (albeit to connect to the same Exchange server).

, , Exchange - "" , , SMTP, . SMTP- , , SMTP- , .

, , . ?

UPDATE

@MichaelEvanchik, Wireshark, , 30- , Exchange. , 30 , , " ". , , , . , .

# 2

, -, ​​30- , , , . , - " ​​ ", , , , , Exchange, .

+2
1

Wireshark . =]

, http- SMTP.

0

Source: https://habr.com/ru/post/1717643/


All Articles