Couple of possible problems I see with the M-SEARCH (or not 100% compliance in any case):
- should have an empty line in the end
- Max value of MX is 5
About not receiving replies: There may of course be a reason (a bug) for the missing messages but note that you absolutely cannot trust on message delivery as this is UDP and not TCP. This is why even according to spec every M-SEARCH should be sent several times.
If I recall correctly UPnP spec vaguely suggests "hundreds of milliseconds" as the minimum repeat frequency for discovery messages.
The source for all of the above is UPNP arch document or rather my memory of it. I'm almost 100% sure that DLNA has extra requirements on these things but I can't remember those off the top of my head... These possible extra requirements probably shouldn't make devices not respond to you though.
EDIT: Oh heck, I had the DLNA spec open so why not: You should send more than 1 M-SEARCH. Should not exceed 10 M-SEARCHes per any 200 ms period. The original and duplicates should be sent inside 10 secs. You should wait for replies for MX
seconds plus a second or two for any network delays.
UPnP Device Architecture (UDA) documentation
(formerly known as the DCP Framework)
Specifications:
- UPnP Device Architecture 2.0, Document Revision Date 17 April 2020
- UPnP Device Architecture 1.1, Document Revision Date 15 October 2008
- UPnP Device Architecture 1.0, Document Revision Date 24 April 2008
- UPnP Device Architecture 1.0, Document Revision Date 20 July 2006
- UPnP Device Architecture 1.0, Document Revision Date 8 June 2000
- UPnP Device Architecture 1.0, Annex A – IP Version 6 Support
Further documentation: