2011-08-21 118 views
0

我最初發布這個在亞馬遜SES論壇在這裏:https://forums.aws.amazon.com/thread.jspa?threadID=74561&tstart=0循環HTTP後開始出現故障亞馬遜SES

但由於計算器社會更加活躍,我會在這裏:)張貼

基本上我有一個圍繞cURL帖子的forecah循環(請參閱腳本代碼片段的帖子底部)。它適用於幾百個帖子,但對其他所有人來說都會失敗。這裏的最後一次成功後接着是第一次不成功的職位100的的...

* About to connect() to email.us-east-1.amazonaws.com port 443 (#0) 
* Trying 207.171.162.2... * connected 
* Connected to email.us-east-1.amazonaws.com (207.171.162.2) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSL connection using RC4-MD5 
* Server certificate: 
* subject: /C=US/ST=Washington/L=Seattle/O=Amazon.com Inc./CN=email.us-east-1.amazonaws.com 
* start date: 2010-10-08 00:00:00 GMT 
* expire date: 2013-10-07 23:59:59 GMT 
* subjectAltName: email.us-east-1.amazonaws.com matched 
* issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)09/CN=VeriSign Class 3 Secure Server CA - G2 
* SSL certificate verify ok. 

POST/HTTP/1.1 
Accept: */* 
Host: email.us-east-1.amazonaws.com 
Content-Type: application/x-www-form-urlencoded 
Date: Sat, 20 Aug 2011 18:59:56 UTC 
X-Amzn-Authorization: AWS3-HTTPS AWSAccessKeyId=LKIABMH7PT8SO4YBRDQA,Algorithm=HmacSHA1,Signature=/0HFVEsTBGqUUSQGy9jvmsft2k4= 
Content-Length: 5810 
Expect: 100-continue 

< HTTP/1.1 200 OK 
< x-amzn-RequestId: 4a0f8f18-cb5f-11e0-8364-b14fdafc0888 
< Content-Type: text/xml 
< Content-Length: 326 
< Date: Sat, 20 Aug 2011 19:04:55 GMT 
< 
* Connection #0 to host email.us-east-1.amazonaws.com left intact 
* Closing connection #0 

的失敗開始....

* About to connect() to email.us-east-1.amazonaws.com port 443 (#0) 
* Trying 207.171.162.2... * connected 
* Connected to email.us-east-1.amazonaws.com (207.171.162.2) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSL connection using RC4-MD5 
* Server certificate: 
* subject: /C=US/ST=Washington/L=Seattle/O=Amazon.com Inc./CN=email.us-east-1.amazonaws.com 
* start date: 2010-10-08 00:00:00 GMT 
* expire date: 2013-10-07 23:59:59 GMT 
* subjectAltName: email.us-east-1.amazonaws.com matched 
* issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)09/CN=VeriSign Class 3 Secure Server CA - G2 
* SSL certificate verify ok. 

POST/HTTP/1.1 
Accept: */* 
Host: email.us-east-1.amazonaws.com 
Content-Type: application/x-www-form-urlencoded 
Date: Sat, 20 Aug 2011 18:59:56 UTC 
X-Amzn-Authorization: AWS3-HTTPS AWSAccessKeyId=LKIABMH7PT8SO4YBRDQA,Algorithm=HmacSHA1,Signature=/0HFVEsTBGqUUSQGy9jvmsft2k4= 
Content-Length: 5806 
Expect: 100-continue 

< HTTP/1.1 400 Bad Request 
< x-amzn-RequestId: 4b8f29db-cb5f-11e0-b9af-33e5c8fc863b 
< Content-Type: text/xml 
< Content-Length: 347 
< Date: Sat, 20 Aug 2011 19:04:58 GMT 
< 
* Connection #0 to host email.us-east-1.amazonaws.com left intact 
* Closing connection #0 

這裏的腳本片段

foreach($JSONarray['DATABASE'] as $E) 
{ 
     if ((array_diff($E['LISTS'], $FILTER) != $E['LISTS']) && $E['STATUS'] == "CONF") 
     { 
     $MAIL = "Action=SendEmail&Source=".$FROME."&ReturnPath=".$BOUNCE."&Destination.ToAddresses.member.1=".$TOE."&Message.Subject.Data=".$SUBE."&Message.Body.Html.Data=".$BODYE;   
     //curl 
     $aws = curl_init(); 
     curl_setopt($aws, CURLOPT_POSTFIELDS, $MAIL); 
     curl_setopt($aws, CURLOPT_HTTPHEADER, $headers); 
     curl_setopt($aws, CURLOPT_HEADER, false); 
     curl_setopt($aws, CURLOPT_URL, $url); 
     curl_setopt($aws, CURLOPT_RETURNTRANSFER, true); 
     curl_setopt($aws, CURLOPT_VERBOSE, true); 
     curl_setopt($aws, CURLOPT_STDERR, $SESLOG); 
     curl_exec($aws); 
     curl_close($aws); 
     } 
} 

有任何想法嗎?

回答

0

我想通了這個問題:

<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/"> 
<Error> 
<Type>Sender</Type> 
<Code>RequestExpired</Code> 
<Message>Request timestamp: Mon, 22 Aug 2011 15:49:11 UTC expired. It must be within 300 secs/ of server time.</Message> 
</Error> 
<RequestId>0e3899cb-ccd7-11e0-9f09-c5d12d442026</RequestId> 
</ErrorResponse> 

我的頭都SET-在捲曲附近的forecah循環之外。衛生署!所以我只是將這些代碼移入循環來解決超時問題。

0

它可能是一個DOS預防mecanism踢?如何在你的代碼中加入一些睡眠?我肯定會放一些保護措施,制止潛在的DOS攻擊,如果我是亞馬遜..

只是一個猜測,但...

+0

我有能力通過我的亞馬遜賬戶發送5篇/秒。我沒有包含它,但是這個腳本在循環中有一個usleep命令來限制每秒1個帖子。 – johnwhitney