1

I am new to onem2m and using the IoTDM Karaf implementation to learn the initial steps. I am also using the postman bundle from the same project as a learning tool. I am able to do CRUD operations and other straight forward operations from my own code (html,ajax,php) also. I have gone through the spec docs (not the full bundle though, but quite a bit) and the developer guide example of home lighting and implementation examples.

Where I am stuck now is that I have registered for a subscription successfully with notification uri "nu" pointing to a php in a different apache server on the same network. Postman / Google Rest Client can post data to it. I have even added a CORS header to avoid any doubts. I have specified the "nu":http//full IP/phpfile.php. Then I create a content instance from Postman. I am expecting my php to get called. Is this expectation valid?

I am just dumping the post data into a file in my /var/www/html folder. This works as expected. I tested writing a small html and ran it from another server. So it is not a CORS problem or file system access problem. Is the notification implementation in place? My interest is not in the IoT edge device side but in the backend where I want to gather the data from the devices. I do not see any samples detailing the implementation of the notification handler as such.

Any pointers, even if not a direct answer will help. Thanks in advance.

Andreas Kraft
  • 3,754
  • 1
  • 30
  • 39
Madhan M
  • 11
  • 2

2 Answers2

0

When creating a <subscription> resource the hosting CSE may send a notification to perform a subscription verification. The receiver of this verification is the notificationURI set in the <subscription>. This way the CSE is sure that the receiver is indeed the one that can and should handle the notifications.

For this the notification receiver (your PHP script) must be running and answer the verificationRequest correctly, before you create the <subscription> resource. Otherwise the CSE must not send notifications to the given URI.

Was your notification receiver up and running and did it answer the verificationRequest correctly?

See also "TS-0004 - Service Layer Core Protocol Specification", chapter "7.5.1.2.2 Notification for <subscription> resources".

Update

A notification server should check the content of the POST request for a vrq element. This indicates a verification request. If the servers wants to accept the request, it should return the HTTP error code "200" as well as the response header "X-M2M-RSC" with a value of "2000".

Andreas Kraft
  • 3,754
  • 1
  • 30
  • 39
  • The script is reachable but I was not aware of the verification request. Will work on that and update. Thanks for the direction. – Madhan M Feb 08 '19 at 06:28
  • Hi Akr, a bit more digging. I blindly dumped the headers I am getting in my php, the logic being the verificationRequest will hit my handler and I will at least know something called my routine. But nothing. As usual, I checked posting from another browser and I get the headers dump in my log file. – Madhan M Feb 08 '19 at 09:51
  • Oops! Enter posted it instead of newline :-) Newbie issues. Anyway, I also can see the subscription listed in the discoverAllChildren of the CSE. Does that mean the subscription is accepted? Anyway, I am continuing reading through the docs. Will update as I find anything more. – Madhan M Feb 08 '19 at 09:53
  • You should check the content of the POST request for a **vrq** element. This indicates a verification request. If you want to accept the request, you should return the HTTP error code "200" as well as the response header "X-M2M-RSC" with a value of "2000". – Andreas Kraft Feb 08 '19 at 10:31
  • No progress. It is nothing to do with **vrq**. I just added a file_put_contents() with $_SERVER['REQUEST_METHOD'] in my php. This should basically work as soon as it gets called. Doesn't happen. So conclusion is that my php is not getting called. I am starting to dig into the server code itself and figure things out. Looks like I have to do this the hardway. Thanks for your tips. Will help me when I get past this hurdle! – Madhan M Feb 11 '19 at 09:21
  • Ok, one important point, I was using "Beryllium" of the OpenDayLight version. Just found out it is very old. Trying newer versions now. "Oxygen" does not have IoTDM feature plugin in it. The Rabbit Hole goes deeper and deeper :-) – Madhan M Feb 11 '19 at 11:38
  • Hi Akr, Is there an alternative to the Opendaylight IoTDM project? Which one do you use? I have a feeling I am struggling with an unsupported implementation! Do you know if this implementation supports notification? Thanks and sorry for the trouble. – Madhan M Feb 11 '19 at 11:57
  • I personally have no hands-on experience with OpenDayLight, so I don't know whether notifications are actually implemented. As an alternative you may have a look at the following open source implementations. The first one is *Eclipse om2m* (https://www.eclipse.org/om2m/, here you should use the latest development version), the other one is Mobius (http://developers.iotocean.org/archives/module/mobius). I hope you get notifications up and running soon, they are really useful in a lot of scenarios. – Andreas Kraft Feb 11 '19 at 21:00
0

Big leap. I got the notification handler to hit my callback php. Firstly, I used the "carbon" release of ODL IoTDM. Then I had to install feature odl-iotdm-onem2m. This one comes with a odl-onem2m-notifier, which I think is the missing component in the older server. Now when I register a subscription, and add a content instance my php gets called.

I don't see a request verification and other such tips from @akr. I guess I have to find a more recent server implementation for that. But I think, this question is answered.

Thanks a lot @akr for your patience and responses.

Madhan M
  • 11
  • 2