-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetToken in SetResponse #251
Comments
Hi. The token is driven by go-coap. But what you can do is that you don't send a response via go-coap/examples/observe/server/main.go Line 78 in 231b8cd
|
I tried, but WriteMessage has no ACK. |
ACK is sent via in separate message. So you just send a CON message. |
Can you please give an example? |
eg: func sendResponse(cc mux.Client, token []byte) error {
m := message.Message{
Code: codes.Content,
Token: token,
Context: cc.Context(),
Body: bytes.NewReader([]byte("data")),
}
var opts message.Options
var buf []byte
opts, n, err := opts.SetContentFormat(buf, message.TextPlain)
if err == message.ErrTooSmall {
buf = append(buf, make([]byte, n)...)
opts, n, err = opts.SetContentFormat(buf, message.TextPlain)
}
if err != nil {
return fmt.Errorf("cannot set content format to response: %w", err)
}
m.Options = opts
return cc.WriteMessage(&m)
}
mux.HandlerFunc(func(w mux.ResponseWriter, r *mux.Message) {
// we send response in another goroutine - so the peer gets separate message
go func() {
time.Sleep(time.Second*10) // do something
err := sendResponse(w.Client(), r.Token)
if err != nil {
log.Printf("Error on transmitter: %v", err)
}
}()
}) |
But where is the ACK? |
It is handled by go-coap via separate message.
Dňa ut 28. 9. 2021, 21:08 Alex ***@***.***> napísal(a):
… But where is the ACK?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#251 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFSKY7UB4NEZMEAQD4YWUPTUEIHDHANCNFSM5EX6YXDA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Well it doesn't. I tried it these days (I used the WriteMessage from the example) and the client (a sensor) isn't receiving the ACK. It only works with SetResponse. |
In
Feel free to reopen the issue. |
Hi
I'm using SetResponse for responses to confirmable requests. Is it somehow possible to set the Token in SetResponse?
SetResponse is using the pool.Message which has SetToken available. So it should be easily possible to add SetToken into SetResponse but it would be a breaking change.
Alex
The text was updated successfully, but these errors were encountered: