Python SSL 通信在读取时挂起,然后发出错误 54 - 连接被对等方重置

发布于 2024-09-10 19:04:21 字数 5757 浏览 2 评论 0原文

我正在使用 Python/suds/python-ntlm 对 Microsoft CRM Web 服务进行 Web 服务调用,但我对该服务的调用在 SSL 读取时被阻止。 CRM 服务提供商提供测试和生产服务,我可以很好地联系测试服务(尽管它没有有用的数据),但主要服务只是阻塞。

这是我中断进程后的堆栈跟踪:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

INFO:root:Getting WSDL from file:///Users/crose/projects/aed/2366/crm/services/metadata.wsdl
DEBUG:suds.client:sending to (https://service.host/MSCrmServices/2007/MetadataService.asmx)
message:
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/crm/2007/WebServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:Execute>
         <ns1:Request xsi:type="ns1:RetrieveAttributeRequest">
            <ns1:MetadataId>00000000-0000-0000-0000-000000000000</ns1:MetadataId>
            <ns1:EntityLogicalName>opportunity</ns1:EntityLogicalName>
            <ns1:LogicalName>new_typeofcontact</ns1:LogicalName>
            <ns1:RetrieveAsIfPublished>false</ns1:RetrieveAsIfPublished>
         </ns1:Request>
      </ns1:Execute>
   </ns0:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"', 'Content-Type': 'text/xml'}
DEBUG:suds.transport.http:sending:
URL:https://service.host/MSCrmServices/2007/MetadataService.asmx
HEADERS: {'SOAPAction': u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"', 'Content-Type': 'text/xml', 'Content-type': 'text/xml', 'Soapaction': u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"'}
MESSAGE:
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/crm/2007/WebServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:Execute>
         <ns1:Request xsi:type="ns1:RetrieveAttributeRequest">
            <ns1:MetadataId>00000000-0000-0000-0000-000000000000</ns1:MetadataId>
            <ns1:EntityLogicalName>opportunity</ns1:EntityLogicalName>
            <ns1:LogicalName>new_typeofcontact</ns1:LogicalName>
            <ns1:RetrieveAsIfPublished>false</ns1:RetrieveAsIfPublished>
         </ns1:Request>
      </ns1:Execute>
   </ns0:Body>
</SOAP-ENV:Envelope>
  C-c C-cTraceback (most recent call last):
  File "sudstest2.py", line 40, in <module>
    attr = metadata_client.service.Execute(mdRequest(*picklist))
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.py", line 539, in __call__
    return client.invoke(args, kwargs)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.py", line 598, in invoke
    result = self.send(msg)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.py", line 623, in send
    reply = transport.send(request)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/https.py", line 64, in send
    return  HttpTransport.send(self, request)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/http.py", line 77, in send
    fp = self.u2open(u2request)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/http.py", line 118, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 429, in error
    result = self._call_chain(*args)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/Users/crose/virtualenv/advanis/src/python-ntlm/ntlm/HTTPNtlmAuthHandler.py", line 96, in http_error_401
    return self.http_error_authentication_required('www-authenticate', req, fp, headers)
  File "/Users/crose/virtualenv/advanis/src/python-ntlm/ntlm/HTTPNtlmAuthHandler.py", line 35, in http_error_authentication_required
    return self.retry_using_http_NTLM_auth(req, auth_header_field, None, headers)
  File "/Users/crose/virtualenv/advanis/src/python-ntlm/ntlm/HTTPNtlmAuthHandler.py", line 80, in retry_using_http_NTLM_auth
    response = h.getresponse()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/httplib.py", line 986, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/httplib.py", line 391, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/httplib.py", line 349, in _read_status
    line = self.fp.readline()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/socket.py", line 397, in readline
    data = recv(1)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/ssl.py", line 96, in <lambda>
    self.recv = lambda buflen=1024, flags=0: SSLSocket.recv(self, buflen, flags)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/ssl.py", line 217, in recv
    return self.read(buflen)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/ssl.py", line 136, in read

KeyboardInterrupt

最终,在等待相当长的时间后,我收到连接错误 54 - 连接被对等方重置。

调试这个问题的最佳选择是什么?

I'm making a web services call to a Microsoft CRM web service using Python/suds/python-ntlm, and my call to the service is blocking on an SSL read. The CRM service provider provides both a testing and a production service, and I can contact the testing service just fine (although it doesn't have useful data on it) but the main service just blocks.

This is the stack trace, after I interrupt the process:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

INFO:root:Getting WSDL from file:///Users/crose/projects/aed/2366/crm/services/metadata.wsdl
DEBUG:suds.client:sending to (https://service.host/MSCrmServices/2007/MetadataService.asmx)
message:
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/crm/2007/WebServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:Execute>
         <ns1:Request xsi:type="ns1:RetrieveAttributeRequest">
            <ns1:MetadataId>00000000-0000-0000-0000-000000000000</ns1:MetadataId>
            <ns1:EntityLogicalName>opportunity</ns1:EntityLogicalName>
            <ns1:LogicalName>new_typeofcontact</ns1:LogicalName>
            <ns1:RetrieveAsIfPublished>false</ns1:RetrieveAsIfPublished>
         </ns1:Request>
      </ns1:Execute>
   </ns0:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"', 'Content-Type': 'text/xml'}
DEBUG:suds.transport.http:sending:
URL:https://service.host/MSCrmServices/2007/MetadataService.asmx
HEADERS: {'SOAPAction': u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"', 'Content-Type': 'text/xml', 'Content-type': 'text/xml', 'Soapaction': u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"'}
MESSAGE:
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/crm/2007/WebServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:Execute>
         <ns1:Request xsi:type="ns1:RetrieveAttributeRequest">
            <ns1:MetadataId>00000000-0000-0000-0000-000000000000</ns1:MetadataId>
            <ns1:EntityLogicalName>opportunity</ns1:EntityLogicalName>
            <ns1:LogicalName>new_typeofcontact</ns1:LogicalName>
            <ns1:RetrieveAsIfPublished>false</ns1:RetrieveAsIfPublished>
         </ns1:Request>
      </ns1:Execute>
   </ns0:Body>
</SOAP-ENV:Envelope>
  C-c C-cTraceback (most recent call last):
  File "sudstest2.py", line 40, in <module>
    attr = metadata_client.service.Execute(mdRequest(*picklist))
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.py", line 539, in __call__
    return client.invoke(args, kwargs)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.py", line 598, in invoke
    result = self.send(msg)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.py", line 623, in send
    reply = transport.send(request)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/https.py", line 64, in send
    return  HttpTransport.send(self, request)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/http.py", line 77, in send
    fp = self.u2open(u2request)
  File "/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/http.py", line 118, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 429, in error
    result = self._call_chain(*args)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/Users/crose/virtualenv/advanis/src/python-ntlm/ntlm/HTTPNtlmAuthHandler.py", line 96, in http_error_401
    return self.http_error_authentication_required('www-authenticate', req, fp, headers)
  File "/Users/crose/virtualenv/advanis/src/python-ntlm/ntlm/HTTPNtlmAuthHandler.py", line 35, in http_error_authentication_required
    return self.retry_using_http_NTLM_auth(req, auth_header_field, None, headers)
  File "/Users/crose/virtualenv/advanis/src/python-ntlm/ntlm/HTTPNtlmAuthHandler.py", line 80, in retry_using_http_NTLM_auth
    response = h.getresponse()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/httplib.py", line 986, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/httplib.py", line 391, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/httplib.py", line 349, in _read_status
    line = self.fp.readline()
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/socket.py", line 397, in readline
    data = recv(1)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/ssl.py", line 96, in <lambda>
    self.recv = lambda buflen=1024, flags=0: SSLSocket.recv(self, buflen, flags)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/ssl.py", line 217, in recv
    return self.read(buflen)
  File "/usr/local/Cellar/python/2.6.5/lib/python2.6/ssl.py", line 136, in read

KeyboardInterrupt

Eventually, I get a connection error 54 - connection reset by peer - from this, after waiting a fair amount of time.

What's my best bet for debugging this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风疏影 2024-09-17 19:04:21

我最好的猜测是,http 标头中的某些内容弄乱了它。您可以尝试在启用调试/详细设置的情况下使用 wget 或curl 进行相同的调用,然后查看它们返回的内容。

也可能是因为快速连续多次登录该服务。我以前遇到过这个问题,但可能不是,但还有其他需要检查的地方。

My best guess is it is getting something in the http headers that are messing it up. You might try making the same call with wget or curl with the debug/verbose settings on and see what they are getting back.

It could also be something with logging in to the service to many times in quick succession. I have ran into this before, but its might not be but its something else to check into.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文