-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Using goPool to process messages #151
Comments
GoPool is used only to process COAP requests in parallel. It doesn't used for DTLS handshake. ld, _ := coapNet.NewDTLSListener("udp4", "", dtlsCfg)
p, _ := ants.NewPool(10000)
sd := dtls.NewServer(dtls.WithGoPool(p.Submit))
sd.Serve(ld) |
Thanks for the example. I've learned after creating this that it indeed doesn't work for the DTLS handshake. Is it correct that the CoAP DTLS server already uses goroutines to handle CoAP requests in there, so by default already handles CoAP requests concurrently? I'm thinking that because of the default for the go pool is the following function https://github.com/plgd-dev/go-coap/blob/v2.0.4/dtls/server.go#L52-L57. goPool: func(f func()) error {
go func() {
f()
}()
return nil
}, |
In coap protocol order of request is not guaranteed (dtls/udp). So yes I want to process request's concurrently by default. (I didn't used ants by default because I don't want to add dependency to go-coap).
Precisly. |
I totally understand. Thanks for elaborating on this topic @jkralik ! |
I'm trying to get the
goPool
option for the DTLS server to work with ants but don't quite get how I'm supposed to use it. My end goal is to be able to process connections/requests in parallel as the the handler currently (withoutgoPool
) seems to be handled serial. I've read in the documentation on theWithGoPool
function that it can be used with ants to spawn go routines.@jkralik Could you please provide an example of how to use
dtls.NewServer
withdtls.WithGoPool
using ants?Regarding the go pool, I expect that it only applies to the handler and thus not to the DTLS handshake, as seems to be called in client connection
Process
function (here), is that correct? And, depending on the answer, would it be possible to to process DTLS handshakes in parallel too? The only hint I have that the DTLS handshakes not in parallel now is based on the DTLS trace logs where it seems to be processed in sequence.For background: I'm using this for communication with embedded devices, which generally take a lot longer for their communication due to the communication protocols (e.g. 2G) used. The full handshake can easily take five seconds, so the ability to process multiple at the same time would be very helpful in keeping the response times down.
The text was updated successfully, but these errors were encountered: