CoAP Gateway

8 minutes read
Edit on GitHub

CoAP Gateway provides API for devices and clients following the Open Connectivity Foundation specification.

SOURCE Copy
Copied
        docker pull ghcr.io/plgd-dev/hub/coap-gateway:latest
    

A configuration template is available on coap-gateway/config.yaml.

PropertyTypeDescriptionDefault
log.dumpBodyboolSet to true if you would like to dump raw messages.false
log.levelstringLogging enabled from level."info"
log.encodingstringLogging format. The supported values are: "json", "console""json"
log.stacktrace.enabledboolLog stacktrace.false
log.stacktrace.levelstringStacktrace from level."warn"
log.encoderConfig.timeEncoderstringTime format for logs. The supported values are: "rfc3339nano", "rfc3339"."rfc3339nano"

CoAP API as specified in the Open Connectivity Foundation - Device to Cloud Services.

PropertyTypeDescriptionDefault
apis.coap.addressstringListen specification <host>:<port> for coap client connection."0.0.0.0:5684"
apis.coap.protocols[]stringProtocol for coap connection. The supported values are: "tcp", "udp" .["tcp"]
apis.coap.externalAddressstringExternal address including public domain/IP for coap client connection."coap-gw.example.com:5684"
apis.coap.maxMessageSizeintMax message size which can be sent/received via coap. i.e. 256*1024 = 262144 bytes.262144
apis.coap.ownerCacheExpirationstringTime limit of how long to keep subscribed to device updates after last use of the given cache item.1m
apis.coap.subscriptionBufferSizeintThe maximum buffer size for one events subscription.1000
apis.coap.messagePoolSizeintDefines the maximum preallocated messages in the pool for parse/create coap messages.1000
apis.coap.keepAlive.timeoutstringTime limit to close inactive connection.20s
apis.coap.blockwiseTransfer.enabledboolIf true, enable blockwise transfer of coap messages.true
apis.coap.blockwiseTransfer.blockSizeintSize of blockwise transfer block.1024
apis.coap.tls.enabledboolIf true, require server certificate for ssl connection.true
apis.coap.tls.disconnectOnExpiredCertificateboolIf true, device with expired certificates will be disconnected.false
apis.coap.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
apis.coap.tls.keyFilestringFile path to private key in PEM format.""
apis.coap.tls.certFilestringFile path to certificate in PEM format.""
apis.coap.tls.clientCertificateRequiredboolIf true, require client certificate.true
apis.coap.tls.identityPropertiesRequiredboolIf true, require EKU with 1.3.6.1.4.1.44924.1.6 and CN with uuid=<deviceID> in client certificate as is defined OCF.true

OAuth2.0 Client is used to issuing an authorization code used by the Onboarding Tool during the device provisioning which is then exchanged for an access token during the SignUp operation.

PropertyTypeDescriptionDefault
apis.coap.authorization.ownerClaimstringClaim used to identify owner of the device. Combination of ownerClaim set to sub is not compatible if at least one authorization provider uses grant type clientCredentials."sub"
apis.coap.authorization.deviceIDClaimstringClaim used to identify device id of the device. Empty means that JWT doesn't contain it.""
apis.coap.authorization.providers[].namestringProvider name, the register request of the device must contain one of the names of providers.""
apis.coap.authorization.providers[].clientIDstringClient ID to exchange an authorization code for an access token.""
apis.coap.authorization.providers[].clientSecretFilestringFile path to client secret required to exchange an authorization code for an access token.""
apis.coap.authorization.providers[].grantTypestringA grant type of OAuth provider specifies how the device signing up process is authorized. Combination of apis.coap.authorization.ownerClaim set to sub is not compatible if at least one authorization provider uses grant type clientCredentials. Supported values: authorizationCode, clientCredentials"authorizationCode"
apis.coap.authorization.providers[].scopesstring arrayList of required scopes.""
apis.coap.authorization.providers[].authoritystringAuthority is the address of the token-issuing authentication server. Services will use this URI to find and retrieve the public key that can be used to validate the token’s signature.""
apis.coap.authorization.providers[].audiencestringAudience of OAuth provider.""
apis.coap.authorization.providers[].redirectURLstringRedirect url used to obtain device access token.""
apis.coap.authorization.providers[].http.maxIdleConnsintIt controls the maximum number of idle (keep-alive) connections across all hosts. Zero means no limit.16
apis.coap.authorization.providers[].http.maxConnsPerHostintIt optionally limits the total number of connections per host, including connections in the dialing, active, and idle states. On limit violation, dials will block. Zero means no limit.32
apis.coap.authorization.providers[].http.maxIdleConnsPerHostintIf non-zero, controls the maximum idle (keep-alive) connections to keep per-host. If zero, DefaultMaxIdleConnsPerHost is used.16
apis.coap.authorization.providers[].http.idleConnTimeoutstringThe maximum amount of time an idle (keep-alive) connection will remain idle before closing itself. Zero means no limit.30s
apis.coap.authorization.providers[].http.timeoutstringA time limit for requests made by this Client. A Timeout of zero means no timeout.10s
apis.coap.authorization.providers[].http.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
apis.coap.authorization.providers[].http.tls.keyFilestringFile path to private key in PEM format.""
apis.coap.authorization.providers[].http.tls.certFilestringFile path to certificate in PEM format.""
apis.coap.authorization.providers[].http.tls.useSystemCAPoolboolIf true, use system certification pool.false
apis.coap.authorization.tokenTrustVerification.cacheExpirationstringDuration for which a valid token is kept in a runtime cache before re-verification is required.30s
Tip

You might have one client, but multiple APIs in the OAuth system. What you want to prevent is to be able to contact all the APIs of your system with one token. This audience allows you to request the token for a specific API. If you configure it to myplgdc2c.api in the Auth0, you have to set it here if you want to also validate it.

plgd hub uses NATS messaging system as an event bus.

PropertyTypeDescriptionDefault
clients.eventBus.goPoolSizeintNumber of routines to process events in projection.16
clients.eventBus.nats.urlstringURL to nats messaging system."nats://localhost:4222"
clients.eventBus.nats.pendingLimits.msgLimitintLimit number of messages in queue. -1 means unlimited524288
clients.eventBus.nats.pendingLimits.bytesLimitintLimit buffer size of queue. -1 means unlimited67108864
clients.eventBus.nats.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
clients.eventBus.nats.tls.keyFilestringFile name of private key in PEM format.""
clients.eventBus.nats.tls.certFilestringFile name of certificate in PEM format.""
clients.eventBus.nats.tls.useSystemCAPoolboolIf true, use system certification pool.false
clients.eventBus.nats.leadResourceType.enabledboolIf true, subscribe to NATS with lead resource type subject token included.false

Client configurations to internally connect to Identity Store service.

PropertyTypeDescriptionDefault
clients.identityStore.grpc.addressstringIdentity Store service address."127.0.0.1:9100"
clients.identityStore.grpc.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
clients.identityStore.grpc.tls.keyFilestringFile path to private key in PEM format.""
clients.identityStore.grpc.tls.certFilestringFile path to certificate in PEM format.""
clients.identityStore.grpc.tls.useSystemCAPoolboolIf true, use system certification pool.false
clients.identityStore.grpc.keepAlive.timestringAfter a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.10s
clients.identityStore.grpc.keepAlive.timeoutstringAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.20s
clients.identityStore.grpc.keepAlive.permitWithoutStreamboolIf true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent.false

Client configurations to internally connect to Resource Aggregate service.

PropertyTypeDescriptionDefault
clients.resourceAggregate.grpc.addressstringResource aggregate service address."127.0.0.1:9100"
clients.resourceAggregate.grpc.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
clients.resourceAggregate.grpc.tls.keyFilestringFile path to private key in PEM format.""
clients.resourceAggregate.grpc.tls.certFilestringFile path to certificate in PEM format.""
clients.resourceAggregate.grpc.tls.useSystemCAPoolboolIf true, use system certification pool.false
clients.resourceAggregate.grpc.keepAlive.timestringAfter a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.10s
clients.resourceAggregate.grpc.keepAlive.timeoutstringAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.20s
clients.resourceAggregate.grpc.keepAlive.permitWithoutStreamboolIf true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent.false
clients.resourceAggregate.deviceStatusExpiration.enabledboolIf true, refresh device online status in short time than sign token expires.false
clients.resourceAggregate.deviceStatusExpiration.expiresInboolThe interval time required for refreshing the online status of the device. The specified interval must be equal to or greater than 1 second.0s

Client configurations to internally connect to Resource Directory service.

PropertyTypeDescriptionDefault
clients.resourceDirectory.grpc.addressstringResource directory service address."127.0.0.1:9100"
clients.resourceDirectory.grpc.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
clients.resourceDirectory.grpc.tls.keyFilestringFile path to private key in PEM format.""
clients.resourceDirectory.grpc.tls.certFilestringFile path to certificate in PEM format.""
clients.resourceDirectory.grpc.tls.useSystemCAPoolboolIf true, use system certification pool.false
clients.resourceDirectory.grpc.keepAlive.timestringAfter a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.10s
clients.resourceDirectory.grpc.keepAlive.timeoutstringAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.20s
clients.resourceDirectory.grpc.keepAlive.permitWithoutStreamboolIf true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent.false

The plgd open telemetry exporter configuration.

PropertyTypeDescriptionDefault
clients.openTelemetryCollector.grpc.enabledboolEnable OTLP gRPC exporterfalse
clients.openTelemetryCollector.grpc.addressstringThe gRPC collector to which the exporter is going to send data""
clients.openTelemetryCollector.grpc.keepAlive.timestringAfter a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.10s
clients.openTelemetryCollector.grpc.keepAlive.timeoutstringAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.20s
clients.openTelemetryCollector.grpc.keepAlive.permitWithoutStreamboolIf true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent.true
clients.openTelemetryCollector.grpc.tls.caPoolstringFile path to the root certificate in PEM format which might contain multiple certificates in a single file.""
clients.openTelemetryCollector.grpc.tls.keyFilestringFile path to private key in PEM format.""
clients.openTelemetryCollector.grpc.tls.certFilestringFile path to certificate in PEM format.""
clients.openTelemetryCollector.grpc.tls.useSystemCAPoolboolIf true, use system certification pool.false
PropertyTypeDescriptionDefault
taskQueue.goPoolSizeintMaximum number of running goroutine instances.1600
taskQueue.sizeintSize of queue. If it exhausted, submit returns error.2097152
taskQueue.maxIdleTimestringSets up the interval time of cleaning up goroutines. Zero means never cleanup.10m
PropertyTypeDescriptionDefault
serviceHeartbeat.timeToLivestringSets the initial validity duration of the coap-gateway instance in the database, with a minimum value of 1 second. This validity is periodically extended until the coap-gateway ends.1m
Note

Note that the string type related to time (i.e. timeout, idleConnTimeout, expirationTime) is decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us”, “ms”, “s”, “m”, “h”.

Oct 1, 2021

Get started

plgd makes it simpler to build a successful IoT initiative – to create a proof of concept, evaluate, optimize, and scale.

Get Started Illustration Get Started Illustration