Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [om2m-dev] OM2M - MQTT Request and Response

Dear Andreas,

Apologies for too many emails !

I realized that MN-CSE needs some more filter criteria;  when I modified the URL as http://localhost:8080/~/mn-cse/mn-name?rcn=5&ty=5,
it returned me the correct response. 

Though I am not very sure why MN-CSE wants extra filter criteria but at least it works. 

Regards,
Samar


On Tue, Mar 11, 2025 at 11:08 PM samar shailendra <samarshailendra@xxxxxxxxx> wrote:
Dear Andreas,

Sorry : A correction, my setup misbehaved partly. I did a re-setup and tried the same.

Apologies for the inconvenience. 


it is resolving to the correct forwarder URL, however as response I still get the Rest CLient Error. This is a bit confusing, because if I try to send the same query (http://127.0.0.1/~/mn-cse/mn-name?rcn=5) using Postman it works.

The error logs
[INFO] - org.eclipse.om2m.binding.http.RestHttpClient
Sending request: RequestPrimitive [operation=2,
 to=http://127.0.0.1:8282/~/mn-cse/mn-name,
 from=admin:admin,
 requestIdentifier=Rsuhas,
 resultContent=5,
 filterCriteria=
 <FilterCriteria>
 createdBefore null
 createdAfter null
 modifiedSince null
 unmodifiedSince null
 stateTagSmaller null
 stateTagBigger null
 expireBefore null
 expireAfter null
 resourceType null
 sizeAbove null
 sizeBelow null
 filterUsage null
 filterOperation null
 limit null
 level null
 offset null
 </FilterCriteria>,
 returnContentType=application/xml,
 requestContentType=application/xml,
 queryStrings={rcn=[5]},
,tokens=null]
[ERROR] - org.eclipse.om2m.core.comm.RestClient
RestClient error
java.lang.NullPointerException
        at java.math.BigInteger.<init>(BigInteger.java:415)
        at java.math.BigInteger.<init>(BigInteger.java:606)
        at org.eclipse.om2m.commons.resource.FilterGroup.getResourceType(FilterGroup.java:328)
        at org.eclipse.om2m.binding.http.RestHttpClient.getParameters(RestHttpClient.java:311)
....

Regards,
Samar


On Tue, Mar 11, 2025 at 10:46 PM samar shailendra <samarshailendra@xxxxxxxxx> wrote:
Hi Andreas,

Thanks a lot, this makes a lot of sense. I tried the request forwarding.


I get an error: Malformed URI.

I then tried the usual approach: http://localhost:8080/~/mn-cse/mn-name?rcn=5

In this case I get: server error (HTTP ERROR: 500) Problem Accessing /~/mn-cse/mn-name , with log as below:
....
[INFO] - org.eclipse.om2m.core.router.Router
Request targeting another CSE, forwarding to Redirector: /mn-cse/mn-name
2025-03-11 22:40:30.027:WARN:oejs.ServletHandler:ERROR:  /~/mn-cse/mn-name
java.lang.NullPointerException
        at org.eclipse.om2m.binding.http.RestHttpServlet.getHttpStatusCode(RestHttpServlet.java:239)
....

Need your advice, what could possibly be the missing piece ?

Regards,
Samar


On Mon, Mar 10, 2025 at 1:04 AM Andreas Kraft <akrzero@xxxxxxxxxxxxxx> wrote:
Hi Samar,

Yes, this is called “request forwarding”. You need to specify the address of the resource you want to access in Service Provider - relative format, e.g. "/mn-cse/mn-name” but target the in-cse for the request. The in-cse is then forwarding the request to the mn-cse and returns its response, respectively.

For http this could look like this : http://incse.host:8080/mn-cse/mn-name?rcn=5”. 
The “~” is just a shortcut for the CSE-ID and would be replaced by “in-cse” in your case. But you don’t want to address resources on the in-cse…

Best
Andreas

On 9. Mar 2025, at 14:33, samar shailendra <samarshailendra@xxxxxxxxx> wrote:

Thanks again, you are correct ! It was my mistake, I did not enable the mqtt plugin in mn-cse. It's working now. 

Is it possible to get the list of resources under MN-CSE by querying IN-CSE ? 

For the moment, when I query the mn-name registered under in-name in the IN-CSE, I do not get the list of resources under mn-name under MN-CSE (i only get the mn-name properties). I am not sure if this is not implemented or I am making some mistake. (I tried it using http as well with no luck "http://localhost:8080/~/in-cse/in-name/mn-name?rcn=5" !)

Regards,
Samar


On Sun, Mar 9, 2025 at 11:26 PM Andreas Kraft <akrzero@xxxxxxxxxxxxxx> wrote:
Hi Samar,

This is an excellent question. I remember that registrations are somehow working in om2m.

He request looks okay (with the previous discussed problems).
Is MQTT enabled for the MN-CSE as well? Have you checked with the MQTT broker that the MN-CSE is really listening?

Best
Andreas


On 9. Mar 2025, at 10:12, samar shailendra <samarshailendra@xxxxxxxxx> wrote:

Thanks a lot Andreas. 

I will give a try to ACME CSE as well. 

For the moment, I am trying to build a mn-cse and in-cse deployment scenario.  One more help I need:

I reckon mn-cse also follows the same request structure and the topic structure. I am able to register the mn-cse with in-cse. However, when I am following the similar payload and topic structure, the mn-cse does not even read the mqtt requests. I am missing something on the topic structure or something else, :-(

topic: /oneM2M/req/CAE_12/mn-cse/json
payload: 
{
  "m2m:rqp": {
    "m2m:fr": "CAE_12",
    "m2m:to": "/mn-cse/mn-name",
    "m2m:op": 1,
    "m2m:rqi": 123456,
    "m2m:pc": {
      "m2m:ae": {
        "rn": "ae-nmcu-mn",
        "api": "api-id",
        "rr": true
      }
    },
    "m2m:ty": 2
  }
}

Regards,
Samar


On Sun, 9 Mar 2025, 6:06 am Andreas Kraft, <akrzero@xxxxxxxxxxxxxx> wrote:
Hi Samar,

Great! I am glad this works for you.

Regarding fixing: It seems there are some activities around om2m currently. I hope that this and some other problems can be easily fixed. But I am not involved.

Payloads: There is the recipes web site I pointed to earlier, though most requests are using http for simplicity. 

But since requests using the MQTT binding are more or less pure oneM2M requests it may be easy to convert them easily.
Another possibility could be the oneM2M tutorials using Jupyter Notebooks: https://wiki.onem2m.org/index.php?title=OneM2M_Tutorials_using_Jupyter_Notebooks
There, for each request the pure oneM2M representation is also presented.

Last but not least a more complicated solution. You can use the ACME CSE and run some test cases with MQTT against it, enabling MQTT instead of http for the tests. When running the test cases in verbose mode the requests are printed to the console. 

(Just to be transparent, I am the author of the ACME CSE)

Best
Andreas


On 8. Mar 2025, at 15:18, samar shailendra <samarshailendra@xxxxxxxxx> wrote:

Dear Andreas,

Thanks a lot. This suggestion did help. I am able to query and create the AE as well.

Create AE payload:
{
  "m2m:rqp": {
    "m2m:fr": "CAE_123",
    "m2m:to": "/in-cse/in-name",
    "m2m:op": 1,
    "m2m:rqi": 123456,
    "m2m:pc": {
      "m2m:ae": {
        "rn": "ae-nmcu",
        "api": "api-id",
        "rr": true
      }
    },
    "m2m:ty": 2
  }
}

As you mentioned, this is definitely not as per the oneM2M defined structure and will break the interoperability of OM2M with other implementations. I am not sure if there are plans to fix this!

Is there any place, I can find some payload structures for different types of requests ?

Regards,
Samar


On Sat, Mar 8, 2025 at 10:48 PM Andreas Kraft <akrzero@xxxxxxxxxxxxxx> wrote:
Samar,

As I wrote, om2m had interoperability problems with the encodings in the past, and it seems to me that unfortunately they have not been solved.
The representations you have are not interoperable with other implementations.

That said, without having it tried myself, I would suggest to add the “m2m:” domain prefix to the attributes in your request, e,g,

{
  "m2m:rqp": {
    “m2m:op": 2,
    “m2m:fr": "CAE",
    “m2m:to": "/in-cse/in-name",
    “m2m:rqi": "123456",
    “m2m:rvi": "1"
  }
}

Does this help?

Best
Andreas


On 8. Mar 2025, at 06:37, samar shailendra <samarshailendra@xxxxxxxxx> wrote:

Thanks Andreas,

I have been following the OM2M document for MQTT bindings MQTT Binding · Wiki · Eclipse Projects / Eclipse OM2M / om2m · GitLab..

Even though I tried without the m2m: rqp structure as you suggested, how it did not work, in fact m2m: rqp seems to be mandatory in OM2M. 

Then I tried just the Get request as follows: 

Topic: /oneM2M/req/CAE/in-cse/json

Get Request Payload:
{
  "m2m:rqp": {
    "op": 2,
    "fr": "CAE",
    "to": "/in-cse/in-name",
    "rqi": "123456",
    "rvi": "1"
  }
}

However still, "No Operation Provided" response is received on Topic: /oneM2M/resp/in-cse/CAE/json

Response Payload :
{
   "m2m:rsp" : {
      "m2m:rsc" : 4000,
      "m2m:pc" : "No Operation provided",
      "m2m:fr" : "/in-cse"
   }
}

I am also attaching the debug logs from OM2M. In this, "Line 1280 to Line 1345" shows that after unmarshalling the requestPrimitive is Empty (Line 1308). Not sure where the mistake is ! Any suggestions would be quite helpful.

Regards,
Samar


On Sat, Mar 8, 2025 at 5:01 AM Andreas Kraft <akrzero@xxxxxxxxxxxxxx> wrote:
Samar,

You should send the request without extra wrapping it in a “m2m:rqp” structure. Also, it misses the “rvi” attribute.  And “fr” should start with a “C” or “S”, but I guess om2m doesn’t do the check. Also, if you want to create an AE, you must provide the necessary <AE> attributes, not a <CNT>.

What worries me is that the response you received seems to have a structure “m2m:rsp”. But that is wrong on so many parts:
- response is not extra wrapped as “m2m:rsp” (ie. The received structure is the response)
- rqi missing
- providing namespace for attributes (one usually does not)
-  “pc” contains a string (should be “m2m:dbg” for an error message)
etc

With MQTT and WS bindings one basically sends the “pure” oneM2M requests.


Best
Andreas



On 7. Mar 2025, at 13:47, samar shailendra via om2m-dev <om2m-dev@xxxxxxxxxxx> wrote:

Dear Team,

I am able to set up oneM2M with Rest MongoDB. 

I am now trying to make MQTT work as well. I have enabled the MQTT bundle, and am able to connect with Mongo DB as well. 

However, when I am sending the request to create AE (or even any retrieve request), it responds on the resp topic saying "No Operation Provided". 

Any advice on what is wrong with the payload json or why the operation is recognized would be very helpful...


The topic that I have used: 

/oneM2M/req/origin/in-cse/json

The payload is : 
{
  "m2m:rqp" : {
    "fr" : "origin",
    "to" : "/in-cse",
    "op" : 1,
    "rqi" : 123456,
    "pc" : {
      "m2m:cnt" : {
        "rn" : "ae-nmcu"
      }
    },
    "ty" : 2
  }
}

The response topic:
/oneM2M/resp/in-cse/origin/json

The response I receive:
{
   "m2m:rsp" : {
      "m2m:rsc" : 4000,
      "m2m:pc" : "No Operation provided",
      "m2m:fr" : "/in-cse"
   }
}

Regards,
Samar


_______________________________________________
om2m-dev mailing list
om2m-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/om2m-dev

<log.out>






Back to the top