According to section 1.3.2 of the UPnP Device Architecture 1.1 the value should have the following syntax:
USER-AGENT: OS/version UPnP/1.1 product/version
The first product token identifes the operating system in the form OS name/OS version, the second token represents the UPnP version and MUST be UPnP/1.1, and the third token identifes the product using the form
product name/product version. For example, “USER-AGENT: unix/5.1 UPnP/1.1 MyProduct/1.0”
This fails twice:
The mandatory second token UPnP/1.1 is missing
The third token contains an invalid 3rd element /1
The first product token should only be OS name/OS version and no combination of app and OS between braces.
When logging the SSDP messages from our iOS app with CocoaUPnP, we see that the M-SEARCH message has multiple issues for the "USER-AGENT" value.
Wireshark Log:
Issues
USER-AGENT: OS/version UPnP/1.1 product/version
This fails twice:
UPnP/1.1
is missing/1
The first product token should only be
OS name/OS version
and no combination of app and OS between braces.The first product token shows the Build value from Xcode as version (
4
in this example), instead of the Version string. Apparently the wrong key is used in_userAgentString
, which should be"CFBundleShortVersionString"
: https://github.com/arcam/CocoaUPnP/blob/3a4b58a82fa0e3db142f5d1be55a98c6c464aac9/CocoaUPnP/Networking/SSDP/SSDPServiceBrowser.m#L307-L311The current version of CocoaSSDP is 2.0.2, not 0.1.0 as used in the user-agent. Root cause: A hardcoded const
SSDPVersionString
is used inSSDPServiceBrowser
: https://github.com/arcam/CocoaUPnP/blob/3a4b58a82fa0e3db142f5d1be55a98c6c464aac9/CocoaUPnP/Networking/SSDP/SSDPServiceBrowser.m#L38Solution To solve all these issues, I would recommend to follow the UPnP docu:
USER-AGENT: OS/version UPnP/1.1 product/version
For this example that would be:
USER-AGENT: iOS/12.4 UPnP/1.1 My App/1.2.3
That would also reduce maintaining
SSDPVersionString
, which obviously will be forgotten for each update.So in code: remove
/1
from USER_AGENT:And apply proper syntax and use of correct keys to create the user-agent value:
And similar for macOS.