Fix for Curl crash in case there is a network timeout

Fix for Curl crash in case there is a network timeout
0.0 0


Hi All,

While working on our cocos2dx game we noticed that the game would occasionally crash when there were timeout errors. I finally decided to dig in look for a solution. Found out that curl apparently fails to send a timeout notification. The proper fix (as noted on the Curl site as well is to set the following curl option in code)

code = curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L); if (code != CURLE_OK) { return false; }

And the best place to do this is in extensions/network/HttpClient.cpp in the following function
configureCURL(CURL *handle)

But since, curl options are static, I suppose this can be done anywhere in the code.

Posting this to validate the solution, and hopefully help someone.

cocos2dx js 3.3, android crash issues summary
BUG: crashes in libcurl when flaky internet

Thank you for this, I haven’t encountered this crash but when I look more into this I’ll be sure to include your solution in my game. Have you submitted an issue to the cocos2d-x team?


We were getting this issue and this fix sorted it… Thanks for sharing. Not sure if a patch is in order.


This is also missing from the AssetsManager class in the extentions. Would probably serve to fix it there as well.

Also, I would really like to submit this fix as a patch, but don’t really know how. Any advice would be appreciated.


@Omer Saeed
You can refer to this document for detail information.

Thanks for sharing.
Waiting for your pull request.


Kool! Thanks for the pointer. Will submit a patch . . .


Will you send a pull request for it?
Did you meet any problem?