2012-03-15 94 views
0

的肥皂錯誤,而試圖對某些URL蟒蛇pycurl給予了GNUTLS

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 

錯誤m到處pycurl是

(56, 'GnuTLS recv error (-9): A TLS packet with unexpected length was received.') 
    @c.perform() 

請建議什麼都可以啦,我怎麼能解決這個問題。 使用Ubuntu和捲曲相同的URL在PHP工作

這是我

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') 
+0

按照這個http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=515200做到了,如果沒有其他解決辦法請建議。 – XMen 2012-03-15 08:37:42

回答

2

這似乎是一個libcurl的問題的GnuTLS編譯。

在別處我讀:

https://bugs.launchpad.net/gwibber/+bug/626023/comments/28也 建議,「我設法擺脫錯誤的唯一方法,就是通過 重新編譯的libcurl使用OpenSSL代替的GnuTLS然後 重新編譯的python-pycurl反對新cURL庫

我重新編譯的libcurl使用OpenSSL的建議和問題解決了我。我已經包括了我的食譜這裏尋找靈感,雖然這是Ubuntu的具體。

#!/bin/bash 

sudo apt-get install libcurl4-openssl-dev 

wget http://curl.haxx.se/download/curl-7.26.0.tar.gz 
wget http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz 
tar -xzvf pycurl-7.19.0.tar.gz 
tar -xzvf curl-7.26.0.tar.gz 
cd curl-7.26.0/ 
./configure --with-ssl 
make 
sudo make install 
cd ../pycurl-7.19.0/ 
sudo python setup.py install 

sudo ldconfig