sae的curl限制能否突破?
我先说下我的情况:
curl到国外的web service上面,发送数据,处理后,再返回数据。
之前使用了美国空间,香港空间,但是总不满意,无法满足国内各地区的快速访问。
所以我现在放到了sae上面运行,但是sae有很多限制的,比如curl的限制如下:
connect_timeout 5秒
send_timeout 15秒
read_timeout 20秒
抓取文件大小 8MB
禁用头,这些头用户无法修改 Content-Length、Host、Vary、Via、X-Forwarded-For、FetchUrl、AccessKey、TimeStamp、Signature、AllowTruncated、ConnectTimeout、SendTimeout、ReadTimeout
目前就是第一条把我给限制住了,后面的限制对我没有影响。
正是由于他的connect_timeout 5秒 限制,导致我的curl应用经常返回502/504错误提示。
这个出错比例大概在3%左右,也就是运行100次,就会出错3次,后来我将curl里的网址由https换成http,这样出错概率降低了不少,但还是存在,测试在1%左右。
对于结果我还是不满意。因为我的curl程序在其他地方(国内三家机房测试)运行都没有出现过错误。
当然我也给sae提出建议,甚至要求升级成付费用户,都没有回复。
惟一的一个管理员说跟我要了curl的网址说帮我找台机器测试看看是不是有这回事。
可能有人说你为什么要在sae这棵树上吊死?
说实话我看中sae的惟一优势是他们是5线机房,国内大部分地区的用户访问速度非常不错的。再说我申请通过开发者认证,每个月的云豆应该足够使用了。
现在似乎有三种选择:
1.继续给sae建议,让他们修改限制参数
2.优化代码?我实在想不出如何优化了
3.放弃sae,这不是我最终想要的结果
我的curl代码是这样的:
#POST方法<br /> $curl = curl_init($url);<br /> curl_setopt( $curl, CURLOPT_POST, 1 );<br /> curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );<br /> curl_setopt( $curl, CURLOPT_HEADER, 0 );<br /> curl_setopt( $curl, CURLOPT_RETURNTRANSFER , 1 );<br /> $response = curl_exec($curl);<br /><br /> #GET方法<br /> $curl = curl_init($url);<br /> curl_setopt( $curl, CURLOPT_GET, 1 );<br /> curl_setopt( $curl, CURLOPT_GETFIELDS);<br /> curl_setopt( $curl, CURLOPT_HEADER, 0 ); <br /> curl_setopt( $curl, CURLOPT_RETURNTRANSFER , 1 );<br /> $response = curl_exec($curl);
------解决方案--------------------

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version

WebStorm Mac version
Useful JavaScript development tools
