Skip to content

CoAP Resource Discovery Returns 4.04 Not Found

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about CoAP Resource Discovery Returns 4.04 Not Found. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

CoAP /.well-known/core request returns 4.04 (Not Found) instead of resource list.

Quick Fix

Wrong

// Server does not implement /.well-known/core handler```

Client receives 4.04 Not Found when requesting /.well-known/core.


### Right

```cpp
#include <coap.h>

void discovery_handler(coap_context_t *ctx, coap_resource_t *res,
                       coap_session_t *session, coap_pdu_t *request,
                       coap_binary_t *token, coap_string_t *query,
                       coap_pdu_t *response) {
  // Build CoRE Link Format response
  const char *links =
    "</temperature>;rt="sensor.temp";ct=50,"
    "</humidity>;rt="sensor.hum";ct=50,"
    "</actuator/valve>;rt="actuator.valve";ct=0";

  coap_pdu_set_code(response, COAP_RESPONSE_CODE_CONTENT);
  coap_set_header_content_type(response, COAP_MEDIATYPE_APPLICATION_LINK_FORMAT);
  coap_add_data(response, strlen(links),
                (const unsigned char*)links);
}```

Client receives 2.05 with CoRE Link Format: ;rt="sensor.temp";ct=50, ;rt="sensor.hum";ct=50


## Prevention

CoAP resource discovery uses /.well-known/core (RFC 6690). The format is CoRE Link Format (Content-Format 40). Each link includes: path, rt (resource type), if (interface), ct (content type), obs (observable), sz (max size). Clients can filter: /.well-known/core?rt=sensor.temp returns only temperature resources.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

## FAQ

<details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">### What is CoRE Link Format?</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>Format for describing CoAP resources: <path>;attr=value. RFC 6690. Similar to HTTP Link header format.</p>
<h3 id="can-i-filter-discovery">Can I filter discovery?</h3><p>Yes. Query parameters filter results: ?rt=sensor.temp returns only that type. ?href=/temp returns exact path match.</p>
<h3 id="is-discovery-mandatory">Is discovery mandatory?</h3><p>Optional but strongly recommended. Enables machine-to-machine discovery without out-of-band configuration.</p>
</div></details>

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro