Hello Mr. Ben Alaya,
Thank you very much for your response. Now I understand better about the concept of the Base URI and the Target URI.
I tried the method that you gave me, but I didn't get the expected result. In fact, I don't understand the method: notify(RequestIndication) in the class Notifier(package:org.eclipse.o
m2m.core.notifier). In the method, no matter which scenario it is, the target ID is set to "null". It is here that cause
the problem.
public static ResponseConfirm notify(RequestIndication requestIndication){
if(requestIndication.getTargetID().matches(".*://.*")){
requestIndication.setBase(requestIndication.getTargetID());
requestIndication.setTargetID(null);
return new RestClient().sendRequest(requestIndication);
}else{
String sclId = requestIndication.getTargetID().split("/")[0];
if(Constants.SCL_ID.equals(sclId)){
String appId = requestIndication.getTargetID().split("applications/")[1];
Application application = DAOFactory.getApplicationDAO().find(Constants.SCL_ID+"/applications/"+appId);
requestIndication.setBase(application.getAPoC());
requestIndication.setTargetID(null);
return new RestClient().sendRequest(requestIndication);
}else{
return new Redirector().retarget(requestIndication);
}
}
I put the protocol-independent URI as the contact during the creation of the subscription : /nscl/applications/LampApp/containers/TestToReceiveFil/contentInstances.
But the destination URI of the notification message is always a combination of the "Base URI" and the " Target URI" , something like: /nscl/applications/LampApp/con
tainers/TestToReceiveFil/contentInstancesNULL.
I am blocked here . Could you please help me to solve this problem?
Thank you for your help.
Best Regards,
Feifei LIU
-------- Original Message --------
Subject: Re: OM2M-problème rencontré
Date: Sat, 14 Jun 2014 14:34:17 +0200
From: Mahdi Ben Alaya <ben.alaya@xxxxxxx>
To: LIU Feifei <feifei.liu@xxxxxxxxxxxx>
CC: ybanouar@xxxxxxx <ybanouar@xxxxxxx>,
Thierry Monteil <monteil@xxxxxxx>
Hello Liu,
You can use our mailing list for future questions, our team will be
happy to answer you. (subscribe here
https://dev.eclipse.org/mailman/listinfo/om2m-dev)
OM2M implements three subscription/notification scenarios: *
Scenario 1 (Your scenario)*
You should use a *protocol-independent* contact URI when you create a
subscription for an Application:
Example:
nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances
<http://itpat1av77:8081/om2m/nscl/applications/APP_648263324/containers/DATA/contentInstances>
*(without http://127.0.0.1:8081/om2m/)*
The GSCL is able to build automatically the full URI based on the "nscl"
stored information using the re-targeting mechanism.
Create subscription Request example:
POST
<nscl-ip>:<port>/om2m/gscl/applications/<app-id>/containers/<cont-id>/contentInstances/subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<om2m:subscription xmlns:tns="http://uri.etsi.org/m2m"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
*
<**om2m:contact>nscl/applications/LampApp/containers/TestToReceiveFile
<http://itpat1av77:8081/om2m/nscl/applications/APP_648263324/containers/DATA/contentInstances>****/contentInstances
<http://itpat1av77:8081/om2m/nscl/applications/APP_648263324/containers/DATA/contentInstances></**om2m:contact>*
</om2m:subscription>
To answer you question related to the "RequestIndication" class, let's
consider the following request:
GET protocol://ip:port/context/path/to/resource
The "base" attribute contains the first part of a URI
(protocol-dependent): protocol://ip:port/context
The "targetID" attribute contains the second part of a URI
(protocol-independent) : path/to/resource
The OM2M core plugin handles protocol-independent requests to make easy
their mapping to specific communication protocols such as HTTP and COAP
(COAP binding will be published soon)
*Scenario 2: *
It is also possible to start an independent server (e.g. listening on
http://192.168.0.2:1400/monitor)
and use it as contact URI for
subscription.
In that case the GSCL will send directly notification to that specific
server.
Remarque: In this example the specific server ip should be reachable by
the GSCL.
See this tutorial:
https://wiki.eclipse.org/OM2M/Manage_Resources#Subscribe_to_MY_SENSOR_data
*Scenario 3:*
If the specific server is not reachable by the GSCL, you can add the
specific listening address as "aPoc" on the subscribed application
representation like this:
Create application Request example:
POST <nscl-ip>:<port>/om2m/nscl/applications
<om2m:application xmlns:om2m="http://uri.etsi.org/m2m"
appId="appTest">
*<om2m:aPoC>http://192.168.0.2:6060/monitor</om2m:aPoC>*
</om2m:application>
Then, you can create a subscription with the URI of the application as
contact URI (the application URI is protocol-independent). In that case
The GSCL is able to re-target notifications to the right NSCL. Finally
the NSCL will notify the specific listening server based on the aPoC tag.
Create subscription Request example:
POST
<nscl-ip>:<port>/om2m/gscl/applications/<app-id>/containers/<cont-id>/contentInstances/subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<om2m:subscription xmlns:tns="http://uri.etsi.org/m2m"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
* <**om2m:contact>**nscl/applications/**appTest**</tns:**om2m>*
</om2m:subscription>
Don't hesitate to contact us if you have any question or remark.
Best regard,
-Mahdi
Le 13/06/2014 19:20, LIU Feifei a écrit :
Bonjour Messieurs,
Je travaille actuellement au sein de Sagemcom et je suis en train de
utiliser votre open source OM2M. Pendant l'utilisation, j'ai rencontré
un problème sur le plateforme NSCL.
Contexte: Une application NA qui est enregistré auprès de nsclBase.
Deux containers dans cette application sont créés. Container 1 est
pour déposer le fichier XML sur le serveur. Container 2 est pour
tester le suscription. Il est un « subscriber » de container 1. Quand
je créée une containerInstance pour container 1, container 1 va
envoyer une notification au container 2 avec la destination défini
dans le "contact" de suscription. Ici, j'ai
mis:*http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances*pour
tester.*
*
voici le résultat:
1. INFO: Notification Request:
RequestIndication
[method=CREATE,*base=null*,*targetID=http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances*,representation=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>
2. INFO: RequestIndication
[method=CREATE,*base=http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances*,*targetID=null*,
representation=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Jun 13, 2014 6:46:29 PM org.eclipse.om2m.comm.http.RestHttpServlet service
3. INFO: HttpRequest
[method=POST,*URI=/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstancesnull*,
representation=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
4. INFO: ResponseConfirm [statusCode=STATUS_BAD_REQUEST,
representation=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<om2m:errorInfo xmlns:om2m="http://uri.etsi.org/m2m"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<om2m:statusCode>STATUS_BAD_REQUEST</om2m:statusCode>
<om2m:additionalInfo>Bad TargetID</om2m:additionalInfo>
</om2m:errorInfo>
, resourceURI=null]
Dans INFO 3, le URI est une combinaison de "Base" et " Target ID",
comme le Target ID est "Null", le URI n'est pas pareil avec le contact
dans le item "subscription".
Dans INFO 4, le server NSCL retourne un résultat "Bad Target ID".
En fait, je ne comprends pas bien l'attribut "Base" /** Request base
uri */ dans le class
RequestIndication(paquet:org.eclipse.om2m.commons.rest). Je n'ai pas
trouvé non plus où cet attribut est donné la valeur dans le class
RestHttpServlet ( paquet: org.eclipse.om2m.comm.http). Est-ce que vous
pouvez m’aider à résoudre ce problème ?
Je vous remercie beaucoup par avance.
Cordialement,
LIU Feifei