in this article, I will share with you how to resolve HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1) error in PHP cURL. recently i was work in one PHP application and I got this issue when I try to call one third party API in my PHP application using the cURL. API working fine in my local but it's not working in my client's live site. when I call API then sometimes got the response and sometimes I got a NULL response from the API server. then i apply curl_error
function in my code and I find the actual issue.
HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1) this issue actually comes when your cURL version is old in your cPanel. but here i resolved this issue add the following line in my cURL request.
Solutions
add the following line in cURL request.
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
i hope you like this small article.