skip to Main Content

I’m trying to connect apache kafka 2.x to eclipse ditto in locally with default configurations.

I’m following this https://www.eclipse.org/ditto/connectivity-protocol-bindings-kafka2.html, so I tried to create a new connection with a POST request, as follows:

curl -X POST -i -u devops:foobar  -H 'Content-Type: application/json' -d '{
   "targetActorSelection":"/system/sharding/connection",
   "headers":{
      "aggregate":false
   },
   "piggybackCommand":{
      "type":"connectivity.commands:createConnection",
      "connection":{
         "id":"kafka123",
         "connectionType":"kafka",
         "connectionStatus":"open",
         "failoverEnabled":true,
         "uri":"tcp://localhost:9092",
         "specificConfig":{
            "bootstrapServers":"localhost:9092"
         },
         "sources":[
            {
               "addresses":["topic01"],
               "consumerCount":1,
               "qos":0,
               "authorizationContext":["nginx:ditto"],
               "enforcement":{
                  "input":"{{ header:device_id }}",
                  "filters":["{{ entity:id }}"]
               },
               "headerMapping":{
                  "topic01":"{{ header:topic01 }}",
                  "the-key":"{{ header:kafka.key }}"
               },
               "payloadMapping":["Ditto"],
               "replyTarget":{
                  "enabled":true,
                  "address":"topic01",
                  "headerMapping":{
                     
                  },
                  "expectedResponseTypes":[
                     "response",
                     "error",
                     "nack"
                  ]
               },
               "acknowledgementRequests":{
                  "includes":[]
               },
               "declaredAcks":[]
            }
         ]
      }
   }
}' 'http://localhost:8080/devops/piggyback/connectivity?timeout=10'

This is the result:

HTTP/1.1 408 Request Timeout
Server: nginx/1.21.6
Date: Wed, 18 May 2022 14:11:33 GMT
Content-Type: application/json
Content-Length: 4
Connection: keep-alive
correlation-id: 16231ebe-3cd1-4ec1-9f42-ad58b9b82d14
timeout: 10
response-required: false
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *

null%        

I can’t understand what I’m doing wrong. how can i solve?

2

Answers


  1. Chosen as BEST ANSWER

    I solved: Checking in the ditto-connectivity logs (on docker), I found an error regarding a java library. To solve the problem I followed the installation of ditto again (https://github.com/eclipse/ditto#getting-started).

    After that, the command written in my question worked and I got a 200 response.


  2. Seems nginx could not send your request over to ditto services. Maybe some of ditto services are not running or you are trying to use a wrong port 8080 (if you followed the instructions for ditto setup, it should be 30080).
    Please check if all ditto pods are running (use ‘kubectl get pods’) and which port your ditto listen on (use ‘kubectl get svc’)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search