Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with custom-ditto-java-payload-mapper #90

Open
kulta4 opened this issue Feb 25, 2024 · 9 comments
Open

Issue with custom-ditto-java-payload-mapper #90

kulta4 opened this issue Feb 25, 2024 · 9 comments
Labels

Comments

@kulta4
Copy link

kulta4 commented Feb 25, 2024

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

@thjaeckle
Copy link
Member

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.

@kulta4
Copy link
Author

kulta4 commented Feb 26, 2024

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

@kulta4
Copy link
Author

kulta4 commented Feb 26, 2024

image

logs

@thjaeckle
Copy link
Member

Which version of Ditto are you running?

@kulta4
Copy link
Author

kulta4 commented Feb 26, 2024

"service":"ditto-gateway-service","service-version":"3.5.2"

@kulta4
Copy link
Author

kulta4 commented Feb 26, 2024

{
"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.(org.apache.pekko.actor.ActorSystem,com.typesafe.config.Config)"
}

@kulta4
Copy link
Author

kulta4 commented Feb 26, 2024

can anyone please help me to fix this

@thjaeckle
Copy link
Member

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:

<ditto.version>3.0.0</ditto.version>

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.

@kulta4
Copy link
Author

kulta4 commented Feb 27, 2024

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": ": 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."
}
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants