IPWorks IoT 2020 JavaScript Edition

Questions / Feedback?

RequestComplete Event

Fires when a request completes.


coap.on('RequestComplete', listener: (e: {readonly method: number, readonly URI: string, readonly requestId: string, readonly errorCode: number, readonly errorDescription: string}) => void )


This event fires when a request completes. Usually, a request is considered complete when a response has been received. However, requests can also be considered "complete" if either of the following occurs:

  • If the UseConfirmableMessages property is enabled, and the class did not receive confirmation that the request was received before the retransmission period elapsed.
  • If Timeout property is greater than 0, and the class did not receive a response before the timeout period elapsed.

Assuming a response was received (i.e., the ErrorCode parameter is either 0 or 709; see below), then the response code, payload, and options can be obtained by querying the ResponseCode, ResponseData, ResponseContentFormat, ResponseETag, and ResponseOption* properties.

The Method parameter reflects the request method code. The following table provides a (non-exhaustive) list of some of the more common method codes; refer to the IANA's CoAP Method Codes registry for a full list.

Method Code Name

The URI parameter reflects the requested resource's URI.

The ErrorCode parameter indicates whether the request encountered an error. If no error was encountered, it will be 0; if the server returned a non-2.xx response code, it will be 709; if some other error occurred (e.g., the request timed out), it will be another non-zero value.

The ErrorDescription parameter provides a description of the error that occurred (or, if ErrorCode is 709, a string version of the response code returned by the server). It will be empty if no error was encountered.

Note: This event is only used when the class is operating in client mode (i.e., when the Listening property is disabled).

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 JavaScript Edition - Version 20.0 [Build 8265]