fiware-sth-comet
fiware-sth-comet copied to clipboard
Configured Cygnus with STH-comet, but unable to retrieve data from Mongo DB
I have configured Cygnus and STH Cygnus is getting subscribed data from orion and storing it in mongo DB But I am unable to fetch data from STH
When I try to get data, it returns response with empty values array. However I can see the data in Mongo DB
We would need more detail about your case, please. In particular:
- Which exact request are you using to fetch data (verb + URL + headers)
- Which response (payload + headers) do you get to that request
- A sample of the documents you see in Mongo DB
Thanks!
- The DB snapshot:
- This is the request I am using to get data:
curl --location --request GET "http://localhost:8666/STH/v1/contextEntities/type/multiSensor/id/urn:ngsi-ld:70-B3-D5-D7-20-1C-01-A7/attributes/Temperature?lastN=10"
--header "fiware-service: myHome"
--header "fiware-servicepath: /building7"
- The response I am getting: {"contextResponses":[{"contextElement":{"attributes":[{"name":"Temperature","values":[]}],"id":"urn:ngsi-ld:70-B3-D5-D7-20-1C-01-A7","isPattern":false,"type":"multiSensor"},"statusCode":{"code":"200","reasonPhrase":"OK"}}]}r
Could you also include the fragment of the log that you get in STH when you run that GET request, please? (only the fragment, not the full log).
Thanks!
Log file showing logs for Manual as well as Wirecloud Hist Module (http://124.109.46.189:8666/STH/v1/contextEntities/type/multiSensor/id/urn:ngsi-ld:70-B3-D5-D7-20-1C-01-A7/attributes/Temperature?lastN=10) GET Requests
This seems to be the root cause of the problem:
Could you re-do the test but this time with STH running in DEBUG log level? Let's try to find to which collection is STH trying to acces...
But as you can see, the collection exists in Mongo DB with latest data
Well... in Mongo DB exists a collection with data but we don't know the collection to which STH is trying to access (or at least I haven't seen in the log fragment you sent... maybe I missed?).
Thus, let's try to find the collection to which STH is trying to access, in order to ensure is the same exists in MongoDB. Not sure but maybe log traces in DEBUG level could provide that information.
In addition, the config.js
file used by STH should be useful.
-
Response on STH Startup:
-
Response on GET:
- Subscription logs:
How are you feeding STH? Notifications are sents to Cygnus or to STH directly?
In the issue body you say you are using Cygnus and in that case Cygnus writes directly to MongoDB. However I see a POST /notify
in the STH traces:
Could you clarify the situation, pls?
That could be the problem I am notifying to "url": "http://sth-comet:8666/notify"
The recommended way of storing data in STH in production is through Cygnus (see https://stackoverflow.com/questions/56461642/sth-comet-raw-insert-in-mongo-database). However, for testing is fine using the /notify endpoint (in fact, in this situation is is even better, to reduce complexity).
Thus, let's focus in that case (i.e. using the /notify endpoint). I'd recommend to do a full clean up before continue debugging, I mean to drop all the STH-related databases.
Which configuration is STH using (i.e. the content of the config.js file)? As far as I remember there are different ways of structuring collections in STH (specified in the config.js file) and there could be some mismatch in the way data is inserted and retrieved.
Now I am facing Connection issues:
Now seems like cygnus is working properly and persisting data to mongoDB.
But still when I query sth:
curl -G -X GET 'http://124.109.46.189:8666/STH/v1/contextEntities/type/multiSensor/id/urn:ngsi-ld:70-B3-D5-D7-20-1C-01-A7/attributes/Temperature'
-d 'lastN=3'
-H 'fiware-service: myHome'
-H 'fiware-servicepath: /building7'
It returns empty array.
Ok, let's start from your last comment and forget all the previous history (Cygnus vs. direct notification confusion, connections, problems, etc.) :)
Which config.js
configuration are you using for STH? Could you post the content of that file in a new comment?
In addition, do the following to ensure we start from a clean situation:
- Stop Cygnus
- Remove all DB in MongoDB
- Start Cygnus
- Send several notifications to Cygnus so new database is created. Which DB and which collections inside it are created?
@Saadiatalkpool
Were you able to solve this problem with STH-Comet?
I have the same problem and I have not found a solution.
@Saadiatalkpool
Were you able to solve this problem with STH-Comet?
I have the same problem and I have not found a solution.
@Rosiberto do you mean same problem described in issue https://github.com/telefonicaid/fiware-sth-comet/issues/545 ?
@fgalan,
Yes. I opened this issue #545 here.
I have the same problem. And so far, I haven't been able to solve it myself and I haven't found a solution online.