-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
localhost mqtt broker with ditto connection #2775
Comments
could you provide mosquitto config? |
Yeah sure this is my mosquitto.conf file. listener 1883 |
sorry, yea.. forgot to ask for mosquitto logs too. |
This is mosquitto logs. 1679896571: mosquitto version 2.0.15 starting |
ugh.. coffee hasn't kicked in. simply put; all containers has their own localhost (unless net is set to host). you need to have a testconnection config to reach the mosquitto container in some appropriate way. localhost for where you have testconnection != localhost for mosquitto, |
Okay, so could you please help me to how I can my testconnection confiig to reach the mosquitto dokcer container . |
easiest would probably to just throw in the mosquitto service into the deployment file of ditto, then use |
Sorry @Daedaluz I can't get you . |
Actually I also got the same issue , can you please elaborate more about this |
I did this but it gives me a null response error. |
how does your docker-compose file look like now then? |
My docker-compose file looks like this: version: '3' services: policies: things: things-search: connectivity: gateway: swagger-ui: nginx: mosquitto: volumes: |
what does "null" error response mean? or is the url supposed to be a websocket url, hence the websocket configuration? |
no it's not work |
No it didn't work I got this kind of error { |
websocket url didn't work either? |
I think connection is establish with tcp:https://mosquitto:1833, but I got error with mosquitto-client sub-pub Unable to connect (Lookup error.). |
is there any update regarding this @Daedaluz @Gauravmeenu @thjaeckle |
Actually, I'm using MQTT broker in localhost with the help of docker image, and along with I'm also running eclipse ditto with docker-compose up as given in the ditto deployment GitHub repo. whenever I'm trying to testconnection with mqtt tcp localhost protocol it gives me an error like as given below .
{
"status": 504,
"error": "connectivity:connection.failed",
"message": "The Connection with ID 'mqtt-connection-source44' failed to connect.",
"description": "Could not establish a connection on 'localhost:1883'. Make sure the endpoint is reachable and that no firewall prevents the connection."
}
But when I'm trying to connect with mosquitto public server test.mosquitto.org it works fine.
#testconnection file given below
{
"targetActorSelection": "/system/sharding/connection",
"headers": {
"aggregate": false
},
"piggybackCommand": {
"type": "connectivity.commands:testConnection",
"connection": {
"id": "mqtt-connection-source44",
"connectionType": "mqtt",
"connectionStatus": "open",
"failoverEnabled": true,
"uri": "tcp:https://localhost:1883",
"sources": [{
"addresses": ["my.sensors/#"],
"authorizationContext": ["nginx:ditto"],
"qos": 0,
"filters": []
}],
"mappingContext": {
"mappingEngine": "JavaScript",
"options": {
"incomingScript": "function mapToDittoProtocolMsg(headers, textPayload, bytePayload, contentType) {const jsonString = String.fromCharCode.apply(null, new Uint8Array(bytePayload)); const jsonData = JSON.parse(jsonString); const thingId = jsonData.thingId.split(':'); const value = {measurements: {properties: {temperature: jsonData.temperature, humidity: jsonData.humidity}}}; return Ditto.buildDittoProtocolMsg(thingId[0], thingId[1], 'things', 'twin', 'commands', 'modify', '/features', headers, value);}",
"outgoingScript": "function mapFromDittoProtocolMsg(namespace, id, group, channel, criterion, action, path, dittoHeaders, value, status, extra) {return null;}",
"loadBytebufferJS": "false",
"loadLongJS": "false"
}
}
}
}
}
The text was updated successfully, but these errors were encountered: