Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Ditto » How do you configure an Http-push connection ?
How do you configure an Http-push connection ? [message #1844160] Fri, 03 September 2021 15:39 Go to next message
Amaury Guichard is currently offline Amaury GuichardFriend
Messages: 3
Registered: September 2021
Junior Member
Hello !
I'm trying to make a custom protocol mapper by implementing the MessageMapper Interface.
If I understood everything correctly, in order for Ditto to use this custom mapper you need to create a new connection.
I tried creating a new http connection but it doesn't seem to work, here is my connection configuration :
{
  "targetActorSelection": "/system/sharding/connection",
  "headers": {
    "aggregate": false
  },
  "piggybackCommand": {
    "type": "connectivity.commands:modifyConnection",
    "connection": { 
        "id":"ocppConnection",
        "name": "ocppConnection",
        "connectionType":"http-push",
        "connectionStatus": "open",
        "uri":"http://localhost:8080",        
        "sources":[],
        "targets": [{
            "address": "PUT:/api/2/chargepoint",
            "authorizationContext": ["nginx:ditto"],
            "headerMapping": {
            "content-type": "application/json"
            },
            "topic":[
                "_/_/things/twin/events",
                "_/_/things/live/commands"
            ],
            "payloadMapping": ["status"]
            }
        ],
        "mappingDefinitions": {
            "status": {
            "mappingEngine": "Ocpp1_6Mapper",
            "options":{}
            
            }
        }
    }
  }
}

localhost:8080 is my ditto "normal" endpoint and is the only URI I can enter without getting an error.
However, when I try a PUT request on http://localhost:8080/api/2/chargepoint I get the following response : "The requested resource could not be found."
I tried everything (using ditto:ditto in the URI, in my request, adding {{ thing:id }} etc...) but I always get the same response and when I check the connection metrics I see that nothing is recognized (I only have 0 at every attributes).
Can someone help me ?
Thx in advance !
Re: How do you configure an Http-push connection ? [message #1844193 is a reply to message #1844160] Mon, 06 September 2021 06:06 Go to previous messageGo to next message
Thomas Jaeckle is currently offline Thomas JaeckleFriend
Messages: 7
Registered: August 2018
Junior Member
Hi.
I guess you are running Ditto in a containerized environment?
Then "localhost" refers to the host of the container Ditto's "connectivity" service is running in. Each Ditto service indeed does open a 8080 HTTP port, but only for health checks. This explains why you can use "localhost:8080" as URI.

So you must use a hostname or an IP address which connects to outside of your containers (or inside of them using a hostname which e.g. Kubernetes or Docker DNS provides for another service you want to connect to).

Best regards
Thomas
Re: How do you configure an Http-push connection ? [message #1844195 is a reply to message #1844193] Mon, 06 September 2021 07:40 Go to previous messageGo to next message
Amaury Guichard is currently offline Amaury GuichardFriend
Messages: 3
Registered: September 2021
Junior Member
Thank you very much !

Is there any example on how to use a java Mapper with an http-push connection ?

I'm on windows, using docker ( docker-compose up -d in the docker deployment folder)

PS : I already rebuilt the project with my new class and modified the docker-compose so that it uses the right build.

[Updated on: Mon, 06 September 2021 07:46]

Report message to a moderator

Re: How do you configure an Http-push connection ? [message #1844291 is a reply to message #1844195] Wed, 08 September 2021 09:00 Go to previous messageGo to next message
Thomas Jaeckle is currently offline Thomas JaeckleFriend
Messages: 7
Registered: August 2018
Junior Member
No, I don't find/remember an example configuring a connection with a custom Java mapper as well.

Did you follow the instructions on how to create one? https://www.eclipse.org/ditto/connectivity-manage-connections.html#retrieve-connection-metrics
When you annotate the mapper with `@PayloadMapper(alias="customMapper")` it should be usable with `"payloadMapping": ["customMapper"]`
Re: How do you configure an Http-push connection ? [message #1844293 is a reply to message #1844291] Wed, 08 September 2021 09:42 Go to previous message
Amaury Guichard is currently offline Amaury GuichardFriend
Messages: 3
Registered: September 2021
Junior Member
I just realized that I mismatched target and source : I thought http-push could only receive message from device but not answer. However it is the exact contrary ^^.
Thank you very much, I'll try something else.
Previous Topic:Does Eclipse Ditto crypto comply with FIPS 140-2?
Next Topic:Integration of Matlab Models in Eclipse Ditto Digital Twins
Goto Forum:
  


Current Time: Sat Nov 26 10:02:26 GMT 2022

Powered by FUDForum. Page generated in 0.02765 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top