I want to use multicurl for the duplex capabilities. The normal curl.perform works fine in keeping the connection alive for a long time.
c = pycurl.Curl()
c.setopt(c.VERBOSE, True)
c.setopt(c.URL, 'https://someurl.com')
c.setopt(c.POSTFIELDS, postfields)
c.perform()
time.sleep(60)
c.perform()
time.sleep(60)
c.perform()
However when I use the following simplified code it drops the connection frequently:
m = pycurl.CurlMulti()
c.setopt(c.POSTFIELDS, postfields)
m.add_handle(c)
while 1:
(result, num) = m.perform()
status = m.select(1)
if num == 0: break
m.remove_handle(c)
time.sleep(10)
repeat this several times
I have tried both HTTP 1.1 and HTTP2 (want to use HTTP2), I cannot figure out where the difference comes from. Version info: PycURL PycURL/7.43.0.5 libcurl/7.68.0 OpenSSL/1.1.1d zlib/1.2.11 c-ares/1.15.0 WinIDN libssh2/1.9.0 nghttp2/1.40.0 (compiled against 0x74400)
Some debug info which might help (They are from different disconnects), None of these errors apear doing repeating curl.perform operations:
old SSL session ID is stale, removing
....
Connection 0 seems to be dead!
Closing connection 0
48 bytes stray data read before trying h2 connection
....
OpenSSL SSL_read: Connection was aborted, errno 10053
Failed receiving HTTP2 data
Connection died, retrying a fresh connect
EDIT: I have found Pycurl 7.43.0 does work correcly with http 1.1, but cannot find a windows build with http2 support.
When I try to build from source I get stuck at step 10: https://github.com/pycurl/pycurl/blob/master/winbuild.py
tar.exe Error (the application was unable to start correctly (0xc000007)
subprocess.CalledProcessError: Command '['c:\Git\usr\bin\tar', 'xf', 'zlib-1.2.11.tar.gz']' returned non-zero exit status 3221225595.
from Pycurl keep alive works with Curl.perform but drops connection frequently when using CurlMulti
No comments:
Post a Comment