When using GrabLib, which uses PyCurl/LibCurl to make requests, I keep getting a timeout error when sending a request. When using the requests module, however, the requests.get method connects to the third-party website with no issues.
Here is my sample code which uses requests and pycurl:
import pycurl
import requests
r = requests.get('http://www.google.com')
print r
c = pycurl.Curl()
c.setopt(pycurl.TIMEOUT_MS, 3000)
c.setopt(pycurl.URL, 'http://www.google.com/')
c.perform()
Here is the output of the code:
<Response [200]>
Traceback (most recent call last):
File "C:/Users/redacted/test2.py", line 10, in <module>
print c.perform()
pycurl.error: (28, 'Resolving timed out after 3000 milliseconds')
Can someone let me know why this may be happening? I'm at a dead end here.
After translating some Russian Google Group comments I've determined that downgrading from "PycURL / 7.43. 0 libcurl / 7.47. 0 OpenSSL / 1.0 2e zlib / 1.2 8 c -.. Ares / 1.10 0 libssh2 / 1.6 0" to "PycURL/7.19.5.3 libcurl/7.45.0 WinSSL zlib/1.2.8" (printed with "print (pycurl.version)") fixes whatever issue I was having. I'm not sure of the intricacies of PyCurl, and what's changed between these versions, so I could not tell you why this was happening. I just know that this resolved the issue for now.
If it helps at all, this started happening when I switched from my work network to my home network; but I also had a VPN that runs on startup (P.I.A.). This leads me to believe that some kind of Windows 10 network setting was the cause of this issue. At first when the problem was occurring, I could reset my machine and it would fix the issue, only for it to happen a bit later (I assume when my VPN connected?). After I went back from my home network to my work network I uninstalled P.I.A., for unrelated reasons, and PyCurl stopped working completely. Again, downgrading fixed the issue for now, for whatever reason.
If anyone can provide more insight into why this might have happened only with PyCurl, then it would be much obliged.
Links for reference:
https://groups.google.com/forum/#!topic/python-grab/PwoplNwa1TI
https://bintray.com/pycurl/pycurl/pycurl/view#files (pycurl-7.19.5.1.win32-py2.7.msi) (I uninstalled pycurl and installed this version on Windows 10 x64)