While trying pycurl for some url
def call_soap_curl(ncServerURL, xml, action):
c = pycurl.Curl()
c.setopt(pycurl.URL, ncServerURL)
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
header=["Content-type: text/xml","SOAPAction:"+action,'Content-Type: text/xml; charset=utf-8','Content-Length: '+str(len(xml))]
print header
c.setopt(pycurl.HTTPHEADER, header)
c.setopt(pycurl.POSTFIELDS, str(xml))
import StringIO
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.perform()
ncServerData = b.getvalue()
return ncServerData
The error m getting is
(56, 'GnuTLS recv error (-9): A TLS packet with unexpected length was received.')
@c.perform()
Please suggest what can be problem , how can i solve this.
Using Ubuntu and same url in curl in php working
This is my
pycurl.version_info()
(3, '7.21.6', 464134, 'x86_64-pc-linux-gnu', 17981, 'GnuTLS/2.10.5', 0, '1.2.3.4', ('dict', 'file', 'ftp', 'ftps', 'gopher', 'http', 'https', 'imap', 'imaps', 'ldap', 'pop3', 'pop3s', 'rtmp', 'rtsp', 'smtp', 'smtps', 'telnet', 'tftp'), None, 0, '1.22')
This seems to be a problem with libcurl compiled with GnuTLS.
Elsewhere I read:
https://bugs.launchpad.net/gwibber/+bug/626023/comments/28 was also
suggested, “The only way i managed to get rid of that error, was by
recompiling libcurl with OpenSSL instead of GnuTLS and then
recompiling python-pycurl against the new cURL library
I recompiled libcurl with OpenSSL as suggested and the problem was solved for me. I’ve included my recipe here for inspiration, though it’s Ubuntu specific.