PHP CURL Memory Leak problem Resolution _php instance

Source: Internet
Author: User
Phpcurl using Privoxy proxy access https://www.google.com/search?q=xxx

Curl configuration is bland, long time running to find a serious problem with memory leaks! Both single-threaded and multi-threaded can not be avoided! It's bug! when Curl accesses the HTTPS site.
Memory leaks can be found through the Linux top command, which is not found using PHP functions Memory_get_usage ().

After repeated debugging to find a solution, curl configuration adds the following to solve the problem:

Copy the Code code as follows:
[Curlopt_httpproxytunnel] = true;
[Curlopt_ssl_verifypeer] = false;
[Curlopt_ssl_verifyhost] = false;

Curlopt_httpproxytunnel specific instructions on StackOverflow, directly affixed to the original:

Without Curlopt_httpproxytunnel

Without curlopt_httpproxytunnel:you just use the proxy address/port as a destination of your HTTP request. The proxy would read the HTTP headers of your query, forward your request to the destination (with your HTTP headers) and T Hen write the response to you.

Example steps:

1) HTTP get/index.html sent to 1.1.1.1 (proxy)
2) 1.1.1.1 receive request and parse header for getting the final destination of your HTTP request.
3) 1.1.1.1 forward your query and headers to www.site.com (destination in request headers).
4) 1.1.1.1 write back to your the response receive from www.site.com

With Curlopt_httpproxytunnel

With curlopt_httpproxytunnel:you ask the proxy to open a direct binary connection (like HTTPS, called a TCP tunnel) dire ctly to your destination by doing a CONNECT HTTP request. When the tunnel is OK, the proxy write your back a http/1.1 Connection established. When it received your browser start-to-Query the destination directly:the proxy does not parse HTTP headers and Theoreti Cally does not read tunnel datas, it just forward it, thats what it is called a tunnel!

Example steps:

1) HTTP CONNECT sent to 1.1.1.1
2) 1.1.1.1 receive HTTP connect and get the Ip/port of your final destination (header field of HTTP connect).
3) 1.1.1.1 open a TCP Socket by doing a TCP handshake to your destination 2.22.63.73:80 (Ip/port of www.site.com).
4) 1.1.1.1 make a tunnel by piping your TCP sockets to the TCP sockets opened to 2.22.63.73:80and then write your back HTTP/1. 1 Connection established witch means that your client can now make your query throw the TCP tunnel (TCP Datas received 'll is transmited directly to server and vice versa).

Http://stackoverflow.com/questions/12288956/what-is-the-curl-option-curlopt-httpproxytunnel-means

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.