Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-8928

[fiware-stackoverflow] FIWARE Cygnus -> cartodb sinks.NGSISink: Persistence error, 400 Bad request

    Details

      Description

      Created question in FIWARE Q/A platform on 31-10-2016 at 20:10
      Please, ANSWER this question AT https://stackoverflow.com/questions/40349517/fiware-cygnus-cartodb-sinks-ngsisink-persistence-error-400-bad-request

      Question:
      FIWARE Cygnus -> cartodb sinks.NGSISink: Persistence error, 400 Bad request

      Description:
      I'm trying to connect cygnus (1.4.0_SNAPSHOT) to cartodb. I run it locally, and I use a script to send a notification to cygnus. The script runs Ok, but cygnus says:

      ERROR sinks.NGSISink: Persistence error (The query 'INSERT INTO jcarneroatos.x002fpeoplelocation (recvtime,fiwareservicepath,entityid,entitytype,the_geom) VALUES ('2016-10-31T19:04:00.994Z','/peoplelocation','Person:1','Person',ST_SetSRID(ST_MakePoint({"coordinates":[-4.423032856,36.721290055]), 4326))' could not be executed. CartoDB response: 400 Bad Request)

      Anyone knows what could be happening? Below I put my config files for information, thanks!

      My username at CARTO is "jcarneroatos", and the domain is https://jcarneroatos.carto.com. This is the script I'm using to simulate the notification from Orion Context Broker:

      #/bin/bash
      HOST=localhost
      PORT=5050
      SERVICE=jcarneroatos
      SUBSERVICE=/peoplelocation

      #send notification
      NOTIFICATION=$(\
      curl http://$HOST:$PORT/notify \
      -v -s -S \
      --header "Content-Type: application/json; charset=utf-8" \
      --header 'Accept: application/json' \
      --header "Fiware-Service: $SERVICE" \
      --header "Fiware-ServicePath: $SUBSERVICE" \
      -d '
      {
      "contextResponses": [
      {
      "contextElement": {
      "attributes": [
      {
      "metadatas": [

      { "name": "location", "type": "string", "value": "WGS84" }

      ],
      "name": "location",
      "type": "geo:json",
      "value":

      { "coordinates": [ -4.423032856, 36.721290055 ], "type": "Point" }

      }
      ],
      "id": "Person:1",
      "isPattern": "false",
      "type": "Person"
      },
      "statusCode":

      { "code": "200", "reasonPhrase": "OK" }

      }
      ],
      "originator": "localhost",
      "subscriptionId": "58178396634ded66caac35b2"
      }')
      if [ -z "$NOTIFICATION" ]; then
      echo "Ok"
      else
      echo $NOTIFICATION
      fi

      This is the structure of the dataset at cartodb:

      x002fpeoplelocation
      cartodb_id | the_geom | entityid | entitytype | fiwareservicepath | recvtime
      number | geometry | string | string | string | date

      This is the cygnus config file:

      cygnusagent.sources = http-source
      cygnusagent.sinks = cartodb-sink
      cygnusagent.channels =cartodb-channel

      cygnusagent.sources.http-source.channels = cartodb-channel
      cygnusagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
      cygnusagent.sources.http-source.port = 5050
      cygnusagent.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.NGSIRestHandler
      cygnusagent.sources.http-source.handler.notification_target = /notify
      cygnusagent.sources.http-source.handler.default_service = jcarneroatos
      cygnusagent.sources.http-source.handler.default_service_path = /peoplelocation
      cygnusagent.sources.http-source.interceptors = ts gi
      cygnusagent.sources.http-source.interceptors.ts.type = timestamp
      cygnusagent.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor$Builder
      cygnusagent.sources.http-source.interceptors.gi.grouping_rules_conf_file = /home/cygnus/APACHE_FLUME_HOME/conf/grouping_rules.conf

      cygnusagent.sinks.cartodb-sink.type = com.telefonica.iot.cygnus.sinks.NGSICartoDBSink
      cygnusagent.sinks.cartodb-sink.channel = cartodb-channel
      cygnusagent.sinks.cartodb-sink.enable_grouping = false
      cygnusagent.sinks.cartodb-sink.enable_name_mappings = false
      cygnusagent.sinks.cartodb-sink.enable_lowercase = false
      cygnusagent.sinks.cartodb-sink.data_model = dm-by-service-path
      cygnusagent.sinks.cartodb-sink.keys_conf_file = /home/cygnus/APACHE_FLUME_HOME/conf/cartodb_keys.conf
      cygnusagent.sinks.cartodb-sink.flip_coordinates = false
      cygnusagent.sinks.cartodb-sink.enable_raw = true
      cygnusagent.sinks.cartodb-sink.enable_distance = false
      cygnusagent.sinks.cartodb-sink.batch_size = 100
      cygnusagent.sinks.cartodb-sink.batch_timeout = 30
      cygnusagent.sinks.cartodb-sink.batch_ttl = 10
      cygnusagent.sinks.cartodb-sink.backend.max_conns = 500
      cygnusagent.sinks.cartodb-sink.backend.max_conns_per_route = 100

      cygnusagent.channels.cartodb-channel.type = memory
      cygnusagent.channels.cartodb-channel.capacity = 1000
      cygnusagent.channels.cartodb-channel.transactionCapacity = 100

      And finally the cartodb_keys.conf file (without key):

      {
      "cartodb_keys": [

      { "username": "jcarneroatos", "endpoint": "https://jcarneroatos.carto.com", "key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }

      ]
      }

      Update:
      After executing Cygnus in DEBUG mode and check the logs, it seems that CARTO is returning:

      {"error":["syntax error at or near \"

      {\""]}

      This the complete log: http://pastebin.com/p9VyUU8n

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 15:12|CREATED monitor | # answers= 2, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 15:12|CREATED monitor | # answers= 2, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 18:08|UPDATED status: transition Answer| # answers= 2, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 18:08|UPDATED status: transition Answer| # answers= 2, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-22 21:08|UPDATED status: transition Finish| # answers= 2, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-22 21:08|UPDATED status: transition Finish| # answers= 2, accepted answer= True

          People

          • Assignee:
            backlogmanager Backlog Manager
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: