ditto-examples
ditto-examples copied to clipboard
Issue with custom-ditto-java-payload-mapper
Hi, I am trying to implement the custom ditto mapper, while to run the connectivity part added volume with jar using the given yaml I unable to create connection it raise an 408 timeout error. can you please help me to fix this issue. Thank you
We can try. Please provide your connection configuration, the payload mapper sources and the command you try to create the connection with? Logs of the connectivity service would also be required to look at.
Hi, yes, this is the command I used to create connection.
curl -i -X POST -u devops:foobar -H 'Content-Type: application/json' --data '{ "connectionType": "mqtt", "connectionStatus": "open", "uri": "tcp://localhost:1883", "failoverEnabled": true, "sources": [ { "addresses": [ "ditto-example-custom-payload-mapper/source" ], "authorizationContext": [ "pre:ditto" ], "headerMapping": { }, "qos": 0, "replyTarget": { "enabled": false, "expectedResponseTypes": [ "response", "error" ] }, "payloadMapping": ["CustomOctopusProtobuf"] } ], "targets": [ { "address": "ditto-example-custom-payload-mapper/target", "authorizationContext": [ "pre:ditto" ], "topics": [ "//things/twin/events", "//things/live/messages" ], "headerMapping": { }, "qos": 0, "payloadMapping": ["CustomOctopusProtobuf"] } ] }' http://localhost:8080/api/2/connections
I follow the same steps which was mentioned in the documentations.
errors: { "status": 408, "error": "command.timeout", "message": "The Command reached the specified timeout of 60,000ms.", "description": "Try increasing the command timeout." }
else it raise: curl: (56) Recv failure: Connection reset by peer
logs
Which version of Ditto are you running?
"service":"ditto-gateway-service","service-version":"3.5.2"
{
"connectionType": "mqtt",
"connectionStatus": "open",
"uri": "tcp://localhost:1883",
"failoverEnabled": true,
"sources": [
{
"addresses": [
"custom-ditto-java-payload-mapper/src"
],
"authorizationContext": [
"pre:ditto"
],
"headerMapping": {
},
"qos": 0,
"replyTarget": {
"enabled": false,
"expectedResponseTypes": [
"response",
"error"
]
},
"payloadMapping": ["CustomOctopusProtobuf"]
}
],
"targets": [
{
"address": "custom-ditto-java-payload-mapper/target",
"authorizationContext": [
"pre:ditto"
],
"topics": [
"//things/twin/events",
"//things/live/messages"
],
"headerMapping": {
},
"qos": 0,
"payloadMapping": ["CustomOctopusProtobuf"]
}
]
}
when I tried with this json(changes in address as folder name) I got some other error
{
"status": 504,
"error": "connectivity:connection.failed",
"message": "The Connection with ID '01fd83de-2f84-4c88-a46f-2b523151210d' failed to connect.",
"description": "org.eclipse.ditto.examples.custompayloadmapper.octopus.OctopusProtobufMessageMapper.
can anyone please help me to fix this
In Ditto 3.4.0, "Akka" was exchanged with "Apache Pekko".
That's why you get NoClassDefFoundError
.
Just replace the import:
import akka.actor.ActorSystem;
with instead:
import org.apache.pekko.actor.ActorSystem;
And (this should be obvious) also update the pom.xml
to point to the Ditto version you are actually using:
https://github.com/eclipse-ditto/ditto-examples/blob/642ffdcf5e2b0ddc00dcd61c1774f77f87a835ef/custom-ditto-java-payload-mapper/pom.xml#L25
Probably the dependency
https://github.com/eclipse-ditto/ditto-examples/blob/642ffdcf5e2b0ddc00dcd61c1774f77f87a835ef/custom-ditto-java-payload-mapper/pom.xml#L47C13-L47C63
has to be replaced with ditto-internal-utils-pekko
then as well.
Thank you I able to make connection now, but this mqtt command [mqtt pub -h mqtt.eclipseprojects.io -p 8883 -s -t ditto-example-custom-payload-mapper/source --message-file example-protobuf-msg] is not working for me I tried this command mosquitto_pub -h localhost -p 1883 -t ditto-example-custom-payload-mapper/source -f example-protobuf-msg put it doesn't give the expected output
curl -i -H 'x-ditto-pre-authenticated: pre:ditto' http://localhost:8080/api/2/things/org.eclipse.ditto:thing-1 HTTP/1.1 200 OK version: 2 correlation-id: c6fd9cae-a230-4077-b2f8-e71529d44008 accept: / ditto-originator: pre:ditto response-required: false etag: "rev:2" Date: Tue, 27 Feb 2024 05:25:59 GMT Content-Type: application/json Content-Length: 78
{"thingId":"org.eclipse.ditto:thing-1","policyId":"org.eclipse.ditto:thing-1"}
so, what is the command and which file we need to send using mqtt
status connection-- { "type": "connectivity.responses:retrieveConnectionStatus", "status": 200, "connectionId": "94c900e8-dc91-4572-93a5-532c6947577a", "connectionStatus": "open", "liveStatus": "misconfigured", "recoveryStatus": "ongoing", "clientStatus": [ { "type": "client", "client": "909efac705f1", "status": "misconfigured", "recoveryStatus": "ongoing", "statusDetails": "<ConnectionFailedException>: The Connection with ID '94c900e8-dc91-4572-93a5-532c6947577a' failed to connect. Could not establish a connection on 'localhost:1883'. Make sure the endpoint is reachable and that no firewall prevents the connection. At 2024-02-27T10:44:02.552379251Z", "inStateSince": "2024-02-27T10:43:12.056646713Z" } ], "sourceStatus": [ { "type": "source", "client": "909efac705f1", "address": "ditto-example-custom-payload-mapper/source", "status": "closed", "statusDetails": "Closed because of unknown/failure/misconfiguration status in client." } ], "targetStatus": [ { "type": "target", "client": "909efac705f1", "address": "ditto-example-custom-payload-mapper/target", "status": "closed", "statusDetails": "Closed because of unknown/failure/misconfiguration status in client." } ] }