search
HomeBackend DevelopmentPHP Tutorialsae的curl限制可否突破

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);

------解决方案--------------------

本帖最后由 PhpNewnew 于 2012-04-22 10:38:04 编辑 对于限制多多的机房我个人是扭头就走的.国内你一般只需要考虑电信网通(现在叫联通?)双线就行了,其他商用接入都是最后接到他们的网上。如果是用空间我还真没啥建议,我没用过任何一款空间,有经济基础的话似乎可以考虑美国的主机,或者香港的主机。

放弃sae 转战阿里云 然后回头来汇报一下情况好给我参考...哈哈哈
云豆够用吗?我不太相信...

至于curl的优化...这还能优化么...
------解决方案--------------------
你应该给出一些测试用的 url
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

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

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

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.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

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

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

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.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

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

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

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.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

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

PHP Email Security: Best Practices for Sending EmailsPHP Email Security: Best Practices for Sending EmailsMay 08, 2025 am 12:16 AM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

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

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 new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools