This article mainly introduces the PHP CURL memory leak Problem Solving method, Crul access to HTTPS site for a long time memory leak problem, this article after repeated debugging found a solution, the need for friends can refer to the
Phpcurl use Privoxy proxy to access https://www.google.com/search?q=xxx
Curl configuration is bland, long run found a serious problem, memory leak! Both single-threaded and multithreading are unavoidable! is curl to visit HTTPS site with bug!
Memory leaks can be found using the Linux top command, Memory_get_usage () with PHP functions.
After repeated debugging to find a solution, the Curl configuration adds the following to solve the problem:
The code is as follows:
[Curlopt_httpproxytunnel] = true;
[Curlopt_ssl_verifypeer] = false;
[Curlopt_ssl_verifyhost] = false;
Curlopt_httpproxytunnel specific instructions on the StackOverflow, directly affixed to the original:
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.
1) HTTP get/index.html sent to 18.104.22.168 (proxy)
2) 22.214.171.124 receive request and parse header for getting the final destination of the your HTTP request.
3) 126.96.36.199 forward your query and headers to www.site.com (destination in request headers).
4) 188.8.131.52 write back to your response receive from www.site.com
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 why it is called a tunnel!
1) HTTP CONNECT sent to 184.108.40.206
2) 220.127.116.11 receive HTTP connect and get the Ip/port of your final destination (header field of HTTP connect).
3) 18.104.22.168 open a TCP Socket by doing a TCP handshake to your destination 22.214.171.124:80 (Ip/port of www.site.com).
4 126.96.36.199 make a tunnel by piping your TCP sockets to the TCP sockets opened to 188.8.131.52: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).