plgd-dev / go-coap

Implementation of CoAP Server & Client in Go
https://coap.technology
Apache License 2.0
435 stars 115 forks source link

Cannot send non-confirmable responses over blockwise udp connection #547

Closed azambranogalbis closed 2 months ago

azambranogalbis commented 3 months ago

Hi!

I have noticed that whenever the blockwise option is enabled in the server, capability to send non-confirmable responses towards the clients is lost.

The key method is Conn.WriteMessage (https://github.com/plgd-dev/go-coap/blob/master/udp/client/conn.go#L498) which executes different paths of code based on the value of the blockWise option.

While having blockWise disabled gives the developer full control on the form of the response (req object gets directly sent over the wire), enabling blockwise ends-up creating a "cloned" req in the newWriteRequestResponse method of blockwise.go (https://github.com/plgd-dev/go-coap/blob/master/net/blockwise/blockwise.go#L267), which is not copying the Type property (which indicates whether the message is or not confirmable). Final result is that all messages missing this property are confirmable by default (https://github.com/plgd-dev/go-coap/blob/master/udp/client/conn.go#L475).

jkralik commented 3 months ago

Thank you for reporting it. If you have the time, could you please fix it? Your help is greatly appreciated.