add config parameter: transport.coap.piggyback_timeout

This commit is contained in:
Jan Christoph Bernack 2022-05-04 17:54:49 +02:00
parent 5f548f2179
commit 80b7b9cee9
No known key found for this signature in database
GPG Key ID: BD807E5761329D0A
6 changed files with 16 additions and 1 deletions

View File

@ -703,6 +703,7 @@ transport:
bind_address: "${COAP_BIND_ADDRESS:0.0.0.0}" bind_address: "${COAP_BIND_ADDRESS:0.0.0.0}"
bind_port: "${COAP_BIND_PORT:5683}" bind_port: "${COAP_BIND_PORT:5683}"
timeout: "${COAP_TIMEOUT:10000}" timeout: "${COAP_TIMEOUT:10000}"
piggyback_timeout: "${COAP_PIGGYBACK_TIMEOUT:500}"
psm_activity_timer: "${COAP_PSM_ACTIVITY_TIMER:10000}" psm_activity_timer: "${COAP_PSM_ACTIVITY_TIMER:10000}"
paging_transmission_window: "${COAP_PAGING_TRANSMISSION_WINDOW:10000}" paging_transmission_window: "${COAP_PAGING_TRANSMISSION_WINDOW:10000}"
dtls: dtls:

View File

@ -38,6 +38,10 @@ public class CoapServerContext {
@Value("${transport.coap.timeout}") @Value("${transport.coap.timeout}")
private Long timeout; private Long timeout;
@Getter
@Value("${transport.coap.piggyback_timeout}")
private Long piggybackTimeout;
@Getter @Getter
@Value("${transport.coap.psm_activity_timer:10000}") @Value("${transport.coap.psm_activity_timer:10000}")
private long psmActivityTimer; private long psmActivityTimer;

View File

@ -29,4 +29,6 @@ public interface CoapServerService {
long getTimeout(); long getTimeout();
long getPiggybackTimeout();
} }

View File

@ -88,6 +88,11 @@ public class DefaultCoapServerService implements CoapServerService {
return coapServerContext.getTimeout(); return coapServerContext.getTimeout();
} }
@Override
public long getPiggybackTimeout() {
return coapServerContext.getPiggybackTimeout();
}
private CoapServer createCoapServer() throws UnknownHostException { private CoapServer createCoapServer() throws UnknownHostException {
Configuration networkConfig = new Configuration(); Configuration networkConfig = new Configuration();
networkConfig.set(CoapConfig.BLOCKWISE_STRICT_BLOCK2_OPTION, true); networkConfig.set(CoapConfig.BLOCKWISE_STRICT_BLOCK2_OPTION, true);

View File

@ -69,6 +69,7 @@ public class CoapTransportResource extends AbstractCoapTransportResource {
private final ConcurrentMap<InetSocketAddress, TbCoapDtlsSessionInfo> dtlsSessionsMap; private final ConcurrentMap<InetSocketAddress, TbCoapDtlsSessionInfo> dtlsSessionsMap;
private final long timeout; private final long timeout;
private final long piggybackTimeout;
private final CoapClientContext clients; private final CoapClientContext clients;
public CoapTransportResource(CoapTransportContext ctx, CoapServerService coapServerService, String name) { public CoapTransportResource(CoapTransportContext ctx, CoapServerService coapServerService, String name) {
@ -77,6 +78,7 @@ public class CoapTransportResource extends AbstractCoapTransportResource {
this.addObserver(new CoapResourceObserver()); this.addObserver(new CoapResourceObserver());
this.dtlsSessionsMap = coapServerService.getDtlsSessionsMap(); this.dtlsSessionsMap = coapServerService.getDtlsSessionsMap();
this.timeout = coapServerService.getTimeout(); this.timeout = coapServerService.getTimeout();
this.piggybackTimeout = coapServerService.getPiggybackTimeout();
this.clients = ctx.getClientContext(); this.clients = ctx.getClientContext();
long sessionReportTimeout = ctx.getSessionReportTimeout(); long sessionReportTimeout = ctx.getSessionReportTimeout();
ctx.getScheduler().scheduleAtFixedRate(clients::reportActivity, new Random().nextInt((int) sessionReportTimeout), sessionReportTimeout, TimeUnit.MILLISECONDS); ctx.getScheduler().scheduleAtFixedRate(clients::reportActivity, new Random().nextInt((int) sessionReportTimeout), sessionReportTimeout, TimeUnit.MILLISECONDS);
@ -353,7 +355,7 @@ public class CoapTransportResource extends AbstractCoapTransportResource {
* Essentially this allows the use of piggybacked responses. * Essentially this allows the use of piggybacked responses.
*/ */
private void deferAccept(CoapExchange exchange) { private void deferAccept(CoapExchange exchange) {
transportContext.getScheduler().schedule(exchange::accept, 500, TimeUnit.MILLISECONDS); transportContext.getScheduler().schedule(exchange::accept, piggybackTimeout, TimeUnit.MILLISECONDS);
} }
private UUID toSessionId(TransportProtos.SessionInfoProto sessionInfoProto) { private UUID toSessionId(TransportProtos.SessionInfoProto sessionInfoProto) {

View File

@ -89,6 +89,7 @@ transport:
bind_address: "${COAP_BIND_ADDRESS:0.0.0.0}" bind_address: "${COAP_BIND_ADDRESS:0.0.0.0}"
bind_port: "${COAP_BIND_PORT:5683}" bind_port: "${COAP_BIND_PORT:5683}"
timeout: "${COAP_TIMEOUT:10000}" timeout: "${COAP_TIMEOUT:10000}"
piggyback_timeout: "${COAP_PIGGYBACK_TIMEOUT:500}"
psm_activity_timer: "${COAP_PSM_ACTIVITY_TIMER:10000}" psm_activity_timer: "${COAP_PSM_ACTIVITY_TIMER:10000}"
paging_transmission_window: "${COAP_PAGING_TRANSMISSION_WINDOW:10000}" paging_transmission_window: "${COAP_PAGING_TRANSMISSION_WINDOW:10000}"
dtls: dtls: