Help and Support
Ask a question, report a problem, request a feature...
<<  Back To Forum

Wrong order of elements in AddPortMapping upnp message

by Guest on 2021/11/02 12:31:29 AM    
Hello,
I found that upnp on my router does not work. It seems Tixati sends upnp elements in wrong order, not as defined by my device specification.

Output of my router (excerpt from http://192.168.0.1/WANIPConnection.xml):
AddPortMapping NewRemoteHost in RemoteHost NewExternalPort in ExternalPort NewProtocol in PortMappingProtocol NewInternalPort in InternalPort NewInternalClient in InternalClient NewEnabled in PortMappingEnabled NewPortMappingDescription in PortMappingDescription NewLeaseDuration in PortMappingLeaseDuration

What Tixati sends (from Tixati upnp log):
[00:16:00]  UPNP mapping UDP port 26676 on gateway 192.168.0.1 - sending AddPortMapping to service WANIPConnection:1
[00:16:00]  UPNP mapping UDP port 26676 on gateway 192.168.0.1 - sending POST command to http://192.168.0.1:80/WANIPConnection
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewEnabled>1</NewEnabled>
<NewExternalPort>26676</NewExternalPort>
<NewInternalClient>192.168.0.27</NewInternalClient>
<NewInternalPort>26676</NewInternalPort>
<NewLeaseDuration>898</NewLeaseDuration>
<NewPortMappingDescription>Tixati</NewPortMappingDescription>
<NewProtocol>UDP</NewProtocol>
<NewRemoteHost></NewRemoteHost>
</u:AddPortMapping>
</s:Body>
</s:Envelope>
[00:16:00]  UPNP mapping UDP port 26676 on gateway 192.168.0.1 - got HTTP response code 500
[00:16:00]  UPNP mapping UDP port 26676 on gateway 192.168.0.1 - got reply:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring>UPnPError</faultstring><detail><UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>402</errorCode><errorDescription>See UPnP Device Architecture section on Control.e:1</errorDescription></UPnPError></detail></s:Fault></s:Body></s:Envelope>
[00:16:00]  UPNP mapping UDP port 26676 on gateway 192.168.0.1 - command failed with error 402 See UPnP Device Architecture section on Control.e:1

If I send it manually as:
<NewRemoteHost></NewRemoteHost>
<NewExternalPort>26676</NewExternalPort>
<NewProtocol>TCP</NewProtocol>
<NewInternalPort>26676</NewInternalPort>
<NewInternalClient>192.168.0.27</NewInternalClient>
<NewEnabled>1</NewEnabled>
<NewPortMappingDescription>Tixati</NewPortMappingDescription>
<NewLeaseDuration>898</NewLeaseDuration>

Then it is succesful:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
   xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <s:Body>
       <m:AddPortMappingResponse
           xmlns:m="urn:schemas-upnp-org:service:WANIPConnection:1">
       </m:AddPortMappingResponse>
   </s:Body>
</s:Envelope>



From Upnp spec, it seems this has changed in version 2.0:

2.5.4 Ordering of Elements
The  order  of  XML  elements  in  device  and  service  description  documents  shall  adhere  to  the  
order  as  defined  in  the  corresponding  specification  as  defined  by  the  working  committee  for  
that  device  or  service  type.  Furthermore,  the  order  of  elements  (e.g.  arguments)  in  control  
messages  and  in  their  responses  shall  adhere  to  the  order  defined  in  the  device’s  service  
description document.
Note:  UPnP  1.0  does  NOT  REQUIRE  that  the  order  of  XML  elements  in  device  and  service  
description  documents  adheres  to  the  order  as  defined  in  the  corresponding  schema  (as  
defined by the working committee) for that device or service type.  However, it does
REQUIRE  that  control  messages  and  responses  are  ordered  according  to  the  corresponding  
device’s  service  description,  a  REQUIREMENT  that  is  sometimes  overlooked.  Therefore,  
when  receiving  messages  from  UPnP  1.0  services,  control  points  should  be  able  to  process  
out-of-order  elements;  and  when  transmitting  messages  to  UPnP  1.0  services,  control  points  
shall send elements in the order defined by that particular device’s service description.


https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf

Tixati v.2.86.

Thanks for looking into it.
by KH on 2021/11/04 04:49:56 AM    
Thanks a ton for catching this one and taking the time to make this detailed post.

This will be corrected in the next release, 2.87.
by Guest on 2021/11/05 11:58:56 PM    
Thank you so much.
by KH on 2021/12/10 07:32:18 AM    
Thanks again for this report.

We released 2.87 today, should be all fixed up now.
by Guest on 2021/12/13 10:10:48 PM    
It works well now. Thank you :-)




This web site is powered by Super Simple Server