Open kim1037 opened 8 months ago
I have a similar problem with a Tapo 500. Basically, nothing works so I captured the traffic and I figured out that the Tapo does not like the GetCapabilities request.
request.xml:
<soap-env:Envelope
xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope">
<soap-env:Header>
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>
xxxxxxxxx
</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
xxxxxxxxxxx
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<ns0:GetCapabilities xmlns:ns0="http://www.onvif.org/ver10/device/wsdl"/>
</soap-env:Body>
</soap-env:Envelope>
When I use curl to do the POST request, it returns an error. I believe that there was not even a reply. The connection is simply closed.
# curl -k -X POST --header 'Content-Type: text/xml; charset=utf-8' -d @request.xml "http://192.168.1.26:2020/onvif/device_service"
curl: (1) Received HTTP/0.9 when not allowed
-:1: parser error : Document is empty
I eventually found what seems to be the problem: The Tapo does not like the self-closing tag <ns0:GetCapabilities ... />
.
For example, the following GetCapabilities request works fine
<?xml version=1.0' encoding='utf-8'>
<soap-env:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<soap-env:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"></GetCapabilities>
</soap-env:Body>
</soap-env:Envelope>
but that one does not
<?xml version=1.0' encoding='utf-8'>
<soap-env:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<soap-env:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</soap-env:Body>
</soap-env:Envelope>
This is quite a problem because there are probably a lot of onvif clients that do not work on the tapo for the same reason.
I will try to fill a ticket at Tp-Link about.
Is there a way to prevent onvif-zeep to produce closing tags?
I figured out how to prevent self-closing tags. The XML is produced in package zeep by the function etree_to_string in wsdl/utils.py
The trick is to insert an empty text in all empty elements so
def etree_to_string(node):
for elem in node.iter():
if elem.text == None:
elem.text = ''
return etree.tostring(
node, pretty_print=False, xml_declaration=True, encoding="utf-8"
)
So I can now successfully do the GetCapabilities and a few other requests.
I still get a disconnection later in my test script but this is probably because I am trying to use an feature that is not supported by my Tapo 500 (i.e. PTZ ContinuousMove)
I noticed some self-closing tag in a network trace from another onvif tool that appears to be working fine so my initial diagnostic is probably incorrect. Something odd is happening here!!!
Hi, I was trying to connect TP-Link tapo C220 ip camera with python, but I 'm stuck on a problem. Here is my code :
When I start this code, it is the error message:
What's wrong with my code? Thanks