HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

  1846 views   2 months ago PHP

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.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on harsukh21@gmail.com

Related Articles