sendgrid / sendgrid-java

The Official Twilio SendGrid Led, Community Driven Java API Library
https://sendgrid.com
MIT License
485 stars 409 forks source link

Scheduled tasks are sent, about three days or so, sendgrid sends emails will be blocked there, no response, and no exceptions are thrown #684

Closed liveforstudy closed 3 years ago

liveforstudy commented 3 years ago

Issue Summary

Scheduled tasks are sent, about three days or so, sendgrid sends emails will be blocked there, no response is given, and no exceptions are thrown, resulting in a backlog of tasks

Steps to Reproduce

  1. This is the first step
  2. This is the second step
  3. Further steps, etc.

Code Snippet

@Configuration
public class SendGridConfiguration {

    public static final String API_KEY = "xxxxxxxxxx";

    @Bean
    public SendGrid sendGrid() {
        return new SendGrid(API_KEY);
    }
}
Request request = new Request();
        request.setMethod(Method.POST);
        request.setEndpoint(SEND_ENDPOINT);
        request.setBody(body);
        Response response = null;
        try {
            response = sendGrid.api(request);
        } catch (IOException e) {
            throw new EmailException("SendGrid error:" + e.getMessage());
        }
        if (response != null && response.getStatusCode() == 202) {
        } else {
            throw new EmailException();
        }

Technical details:

shwetha-manvinkurke commented 3 years ago

@liveforstudy if I understand correctly, you are able to schedule tasks and trigger email sends but those are being blocked by the server? I would reach out to support for help.

liveforstudy commented 3 years ago

@liveforstudy,如果我理解正确,那么您可以安排任务并触发电子邮件发送,但是这些被服务器阻止了?我会伸出手来支持寻求帮助。

No, I don't know the specific reason, because I want to develop a regular mailing, normal test is no problem, but when it is sent for about 1-3 days, there will be no response from sendgrid but sendgrid-java sends api method I have been waiting for a response, resulting in a backlog of tasks. I guess that sendgrid-java is sent using httpclient, and the timeout period is extremely long. I have looked for support, and the support staff called me to github feedback

thinkingserious commented 3 years ago

Hello @liveforstudy,

I'm unsure how we can help here with respect to the helper library. Are you asking about adjusting the timeout values?

With best regards,

Elmer

liveforstudy commented 3 years ago

I need a request to get, you can set the timeout, and timeout exception

JenniferMah commented 3 years ago

Hi @liveforstudy, Are you only seeing problems on scheduled emails after 3 continuous days of sending email? Approximately how many emails are you sending a day?

liveforstudy commented 3 years ago

嗨@liveforstudy, 您是否只在连续 3 天发送电子邮件后看到预定电子邮件出现问题?您一天大约发送多少封电子邮件?

The software developed is mass mailing, with a daily delivery volume of about 100,000

liveforstudy commented 3 years ago

If you send too many requests, your SDK request server will appear similar to thread sleep, blocking there. I use my encapsulated httpclient to directly call the API. Now it has been running normally for more than a month;I've been communicating with you. You've always said that it's my problem, so I don't plan to use your encapsulated sendgrid Java. I find that your sendgrid Java is very difficult to use. I suggest you refer to the SDK writing method of OSS similar to Ali,You can integrate spring boot, but let me question your XXXXX

thinkingserious commented 3 years ago

Hello @liveforstudy,

It seems like there are a few issues here:

  1. You may be running into throttling limitations.
  2. Here is the HTTP client we are using which relies on httpclient. If you prefer, you can provide your own custom client.
  3. You may also find value in the RateLimitException (retry value is set here).

Please let us know if any of these resources are helpful.

Thank you!

With best regards,

Elmer

filwiesner commented 3 years ago

Hello @thinkingserious

Not sure if this is the same problem but I just tried to integrate this library to our backend yesterday and all the requests block indefinetly. I've waited for at least 20 minutes for the request to go through but not even exception was thrown. It was just blocking the thread.

val request = Request().apply {
    method = Method.POST
    endpoint = "mail/send"
    body = mail.build()
}

val response = sendGridService.api(request)
thinkingserious commented 3 years ago

Hello @wooodenleg,

Do you want to timeout after a certain amount of time? If so, you can provide a custom client and set your timeout value. If you require non-blocking requests, you may want to look into async http clients and provide one of those as a custom client.

With best regards,

Elmer

JenniferMah commented 3 years ago

Closing due to inactivity. Feel free to open another issue if further help is needed.

filwiesner commented 3 years ago

Sorry for not responding earlier. I just ended up calling the Sendgrid API on my own.

I didn't want to have a timeout to my request. I wanted to know why doesn't it work and why it just blocks forever. I think there is some bug in this library that causes request to block the thread indefinitely but I didn't investigate it further.

Thanks for your answer anyway and good luck