fiware-sth-comet icon indicating copy to clipboard operation
fiware-sth-comet copied to clipboard

Configured Cygnus with STH-comet, but unable to retrieve data from Mongo DB

Open Saadiatalkpool opened this issue 5 years ago • 18 comments

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

Saadiatalkpool avatar Aug 30 '19 05:08 Saadiatalkpool

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!

fgalan avatar Aug 30 '19 07:08 fgalan

  • The DB snapshot:

2019-08-30 12_58_54-Start

  • 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

Saadiatalkpool avatar Aug 30 '19 08:08 Saadiatalkpool

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!

fgalan avatar Aug 30 '19 12:08 fgalan

2019-08-30 17_42_41-Start 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

Saadiatalkpool avatar Aug 30 '19 12:08 Saadiatalkpool

This seems to be the root cause of the problem:

imagen

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...

fgalan avatar Aug 30 '19 12:08 fgalan

But as you can see, the collection exists in Mongo DB with latest data

Saadiatalkpool avatar Aug 30 '19 12:08 Saadiatalkpool

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.

fgalan avatar Aug 30 '19 12:08 fgalan

  • Response on STH Startup: 3

  • Response on GET: 4

Saadiatalkpool avatar Aug 30 '19 13:08 Saadiatalkpool

  • Subscription logs: 5

Saadiatalkpool avatar Aug 30 '19 13:08 Saadiatalkpool

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:

imagen

Could you clarify the situation, pls?

fgalan avatar Aug 30 '19 13:08 fgalan

That could be the problem I am notifying to "url": "http://sth-comet:8666/notify"

Saadiatalkpool avatar Aug 30 '19 13:08 Saadiatalkpool

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.

fgalan avatar Sep 02 '19 17:09 fgalan

Now I am facing Connection issues: 2019-09-03 16_37_06-Start 2019-09-03 16_38_05-Start 2019-09-03 16_48_47-Start

Saadiatalkpool avatar Sep 03 '19 12:09 Saadiatalkpool

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.

Saadiatalkpool avatar Sep 05 '19 07:09 Saadiatalkpool

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:

  1. Stop Cygnus
  2. Remove all DB in MongoDB
  3. Start Cygnus
  4. Send several notifications to Cygnus so new database is created. Which DB and which collections inside it are created?

fgalan avatar Sep 12 '19 10:09 fgalan

@Saadiatalkpool

Were you able to solve this problem with STH-Comet?

I have the same problem and I have not found a solution.

Rosiberto avatar Jul 09 '20 21:07 Rosiberto

@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 avatar Jul 10 '20 13:07 fgalan

@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.

Rosiberto avatar Jul 11 '20 01:07 Rosiberto