go-ssdp icon indicating copy to clipboard operation
go-ssdp copied to clipboard

Advertise messages do not have HOST: field

Open schwark opened this issue 1 year ago • 1 comments

The missing field is causing SmartThings to ignore the advertisements from go-ssdp.. Not sure which one is not following the spec, but all the other devices on my network do include that field. only the go-ssdp responses do not. The field missing is..

HOST: 239.255.255.250:1900

Looks like the Alive messages do have the field though

schwark avatar Sep 19 '22 04:09 schwark

This fix makes it work for SmartThings..

https://github.com/koron/go-ssdp/commit/66a093adc08534002c1896cc4a97fbdaf08202c8

schwark avatar Sep 19 '22 17:09 schwark

https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03 doens't mentioned about HOST header. But examples include HOST header.

  • M-SEARCH https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03#section-4.2.1.1
  • NOTIFY https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03#section-5.2.1.1
  • NOTIFY https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03#section-5.2.2.1

Ex:

NOTIFY * HTTP/1.1
Host: 239.255.255.250:reservedSSDPport

koron avatar Oct 17 '23 16:10 koron

It looks like reasonable that adding HOST header.

koron avatar Oct 17 '23 16:10 koron

The first article just says that responses for M-SEARCH don't have HOST header.

koron avatar Oct 18 '23 11:10 koron

There are HOST header for requests. It is a natural comparison with HTTP/1.1, which is the basis of SSDP.

But HTTP/1.1 don't require HOST header in responses. Is there a specification or something that requires a HOST header in the response?

koron avatar Oct 18 '23 13:10 koron

Quote last paragrph 4.2 SSDP Discovery Requests > Proposed Solution

Response to ssdp:discover requests SHOULD contain a cache-control: max-age or Expires header. If both are present then they are to be processed in the order specified by HTTP/1.1, that is, the cache- control header takes precedence of the Expires header. If neither the cache-control nor the Expires header is provided on the response to a ssdp:discover request then the information contained in that response MUST NOT be cached by SSDP clients.

koron avatar Oct 18 '23 13:10 koron

AdvertiserOptionAddHost() will support this case. It is add with #38

Example:

a, err := ssdp.Advertise("st", "usn", "location", "server", maxAge, ssdp.AdvertiseOptionAddHost())
...

koron avatar Oct 18 '23 14:10 koron