Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add curl Timeout and Connection Timeout for send function. #15

Closed
wants to merge 1 commit into from

2 participants

Ben Neal Swift
Ben Neal

Add a connection timeout, so if the connection to the server fails or hangs a failed response can be returned to the PHP script. This stops the PHP from timing out waiting for a failed connection or response.

Swift

I'm on the same page about needing timeouts, unclear about what the time should be. Where did you obtain the values you used?

Ben Neal

The values that I have used are from other projects that I have written. I have tried different values but overtime have found this combination has a high success rate.
The connection time out shouldn't need to be over 5 seconds for most requests. The overall timeout will depend on the size of the request. I guess to ensure that this fits most clients requirements someone would need to look at the sendgrid access log and work out the upper boundary for the amount of time each request takes.
I not sure what the average workload would be, but for us, each request was comfortably under 30 seconds.

Hope this helps

Swift

Cool, I went with 5 seconds and 30 seconds respectively. I feel that they are conservative enough and if we run into issues, we can always adjust those.

This went in with 81dd09d, so closing

Swift theycallmeswift closed this April 04, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 21, 2013
Ben Neal Add curl timeouts for Sending email 1c7822e
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 3 additions and 0 deletions. Show diff stats Hide diff stats

  1. 3  SendGrid/Web.php
3  SendGrid/Web.php
@@ -131,6 +131,9 @@ public function send(Mail $mail)
131 131
     curl_setopt($session, CURLOPT_HEADER, false);
132 132
     curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
133 133
      
  134
+    curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 5);
  135
+    curl_setopt($session, CURLOPT_TIMEOUT, 30);
  136
+
134 137
     // obtain response
135 138
     $response = curl_exec($session);
136 139
     curl_close($session);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.