Creating a connection to hono results in "The supplied authentication is invalid"
I would like to connect to my own hono and ditto instaces and followed the tutorial under https://www.eclipse.org/ditto/2018-05-02-connecting-ditto-hono.html
When I try to connect to hono I get the following error: The supplied authentication is invalid.
I'm using the following DevOps command:
{
"targetActorSelection":"/system/sharding/connection",
"headers":{
},
"piggybackCommand":{
"type":"connectivity.commands:createConnection",
"connection":{
"id":"hono-example-connection-123",
"connectionType":"amqp-10",
"connectionStatus":"open",
"failoverEnabled":true,
"uri":"amqp://consumer@Hono:verysecret@url_to_hono:5671",
"authorizationSubject": "ditto:ditto",
"sources":[
{
"addresses":[
"telemetry/org.eclipse.ditto",
"event/org.eclipse.ditto"
]
}
],
"targets":[
{
"address":"events/twin",
"topics":[
"_/_/things/twin/events",
"_/_/things/live/messages"
]
}
]
}
}
}
I'm also confused about the authorizationSubject field because this field is not specified in the connections object under https://www.eclipse.org/ditto/basic-connections.html but used in another example to connect to an AMQP 1.0 endpoint https://www.eclipse.org/ditto/connectivity-protocol-bindings-amqp10.html#establishing-connecting-to-an-amqp-10-endpoint
I'm using the default user for hono and ditto, no other users are created by my own.
Help is appreciated! Thank you!
Hi there.
Ah, regarding the "authorizationSubject" you found an inconsistency - the blog post is right, we replaced the single "authorizationSubject" with the "authorizationContext" containing an array of
authorizationSubject Strings.
We will fix the outdated documentation.
Are you sure that your Hono instance has this user consumer@Hono configured with that password?
I don't know if you have to create the user by yourself or if it automatically exists when starting Hono.
Can you authenticate successfully with for example the Hono client using those credentials?
Hi again,
the user consumer@Hono is existing and I can connect with this credentials via e.g. the example code for the HonoTelemetryConsumer. Is there an defaul authorizationContext I can use or do I have to generate it? and how does such a authorizationContext look like? I also have to mention that I'm using the basic authentication with the default user ditto and the password ditto for the DevOps command, maybe thats the problem?
Ah, ok - that are the wrong credentials for sending a DevOps command.
Default DevOps command user is: devops and password is foobar (as configured here).
The authorizationContext is a list of subjects which should be applied when consuming messages from Hono.
It must contain nginx:ditto if you want to treat all Hono messages in the context of the default Ditto user which is added by default in the .htpasswd
Okay, with the new credentials and the authorizationContext I can send commands but when I want to test the connection I get the following response:
{
"?": {
"-1": {
"type": "connectivity.responses:testConnection",
"status": 409,
"connectionId": "hono-example-connection-123",
"testResult": "Connection was already created - no test possible"
}
}
}
Does this mean ditto is successfully connected to hono?
Testing a connection can only be done if it was not yet created.
So the connection was created, yes. But in order to find out if it is also connected, you have to send a command of "type": "connectivity.commands:retrieveConnectionMetrics" with "connectionId": "yourId"
As documented here
It is working now! Thanky you @thjaeckle !