Comments (4)
Yes there is such option: WithKeepAlive(nil)
https://pkg.go.dev/github.com/go-ocf/go-coap/[email protected]/udp?tab=doc#WithKeepAlive
It is mentioned here: https://tools.ietf.org/html/rfc7252#section-1.2 end of part Reset Message
from go-coap.
Thanks for pointing that out, missed that small section of the RFC.
I'm using DTLS, where that option is not available if I'm not mistaken (https://github.com/go-ocf/go-coap/blob/v2.0.2/server.go#L55). The notes you've referred to are specifically for UDP, and I couldn't find a way that I can pass options to the underlying UDP socket of DTLS.
For reference, I'm using go-coap as follows, where it is imported as coap "github.com/go-ocf/go-coap/v2"
.
err = coap.ListenAndServeDTLS(
"udp4",
fmt.Sprintf(":%v", config.Server.ListenPort),
&dtlsConfig,
mux.HandlerFunc(DefaultHandler),
)
Another question, how should I pass an option, e.g. for keepalive, to dtls.NewServer
? I'm relatively new to Go and don't understand how to pass a server option (e.g. for keepalive
or blockwiseSZX
).
from go-coap.
So If you want to use options you need to create own ListenAndServe:
func ListenAndServe(config Config) error {
l, err := net.NewDTLSListener("udp4", fmt.Sprintf(":%v", config.Server.ListenPort), &dtlsConfig)
if err != nil {
return err
}
defer l.Close()
s := dtls.NewServer(dtls.WithMux(mux.HandlerFunc(DefaultHandler)), dtls.WithKeepAlive(nil), dtls.WithBlockwise(...))
return s.Serve(l)
}
from go-coap.
Good to know that I just have to create my own function for that, it worked as expected. Thanks for showing the example!
from go-coap.
Related Issues (20)
- Move from `pion/udp` to `pion/transport` HOT 3
- Support for Middlewares in mux Router HOT 5
- Consume `pion/dtls` connection ID support HOT 1
- Support serializing and deserializing a UDP DTLS connection HOT 2
- Implement Support for Separate Messages in Server HOT 1
- Server response with ACK to Empty CON (CoAP Ping) HOT 1
- /examples/dtls/cid/server crashes if client has wrong PSK HOT 1
- udp/server_test.go fails if first non-loopback interface is not running HOT 2
- Media type strings do not match IANA registry HOT 5
- Mux provides user with internal map HOT 1
- Ping (CON Empty Message) Notifications HOT 1
- Support for sending messages without token
- Blockwise requests should be correlated based on message options HOT 4
- ListenAndServeWithOptions doesn't correctly start UDP server HOT 1
- Pion pkg/net dependency error HOT 3
- No `NSTART` parameter in TCP transport HOT 2
- Cannot send non-confirmable responses over blockwise udp connection HOT 1
- Custom response messages with type set to ACK send CON HOT 1
- Message cache conflict on block wise transfers with many chunks
- Observe timeout
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-coap.