hyperledger / identus-cloud-agent

Identus Cloud Agent
https://identus.io/
Apache License 2.0
82 stars 22 forks source link

Connection state not updated in the first agent after accepting the connection in the second agent. #866

Closed ndigirigijohn closed 8 months ago

ndigirigijohn commented 9 months ago

Is this a regression?

Yes

Description

The connection state remains the same in the first agent after being accepted in the second agent. Below is a detailed event flow

Initializing a connection to an agent running at localhost 8000: POST /connections http://localhost:8000/prism-agent/ {} is successful, I get the following response: { connectionId: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', thid: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', role: 'Inviter', state: 'InvitationGenerated', invitation: { id: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', type: 'https://didcomm.org/out-of-band/2.0/invitation', from: 'did:peer:2.Ez6LShFpeUGbFu5TxspXAEFeUWV9AxVEsm7ybhfi7ZBNVeULZ.Vz6MkrQgjiLfT3TdC5aHhCHZ9QGkMAzxSuzTWHDv9ykUBcmzP.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19', invitationUrl: 'https://my.domain.com/path?_oob=eyJpZCI6IjE4MzVjNzZlLWI2YjUtNDNlYS1iOTZmLTM4ZDcxZGNhZmQ0NCIsInR5cGUiOiJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzIuMC9pbnZpdGF0aW9uIiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNoRnBlVUdiRnU1VHhzcFhBRUZlVVdWOUF4VkVzbTd5YmhmaTdaQk5WZVVMWi5WejZNa3JRZ2ppTGZUM1RkQzVhSGhDSFo5UUdrTUF6eFN1elRXSER2OXlrVUJjbXpQLlNleUowSWpvaVpHMGlMQ0p6SWpvaWFIUjBjRG92TDJ4dlkyRnNhRzl6ZERvNE1EQXdMMlJwWkdOdmJXMGlMQ0p5SWpwYlhTd2lZU0k2V3lKa2FXUmpiMjF0TDNZeUlsMTkiLCJib2R5Ijp7ImdvYWxfY29kZSI6ImlvLmF0YWxhcHJpc20uY29ubmVjdCIsImdvYWwiOiJFc3RhYmxpc2ggYSB0cnVzdCBjb25uZWN0aW9uIGJldHdlZW4gdHdvIHBlZXJzIHVzaW5nIHRoZSBwcm90b2NvbCAnaHR0cHM6Ly9hdGFsYXByaXNtLmlvL21lcmN1cnkvY29ubmVjdGlvbnMvMS4wL3JlcXVlc3QnIiwiYWNjZXB0IjpbXX19' }, createdAt: '2024-01-26T05:48:46.468250113Z', metaRetries: 5, self: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', kind: 'Connection' }

Accepting the connection POST /connection-invitations http://localhost:9000/prism-agent/ { invitation: 'eyJpZCI6IjE4MzVjNzZlLWI2YjUtNDNlYS1iOTZmLTM4ZDcxZGNhZmQ0NCIsInR5cGUiOiJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzIuMC9pbnZpdGF0aW9uIiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNoRnBlVUdiRnU1VHhzcFhBRUZlVVdWOUF4VkVzbTd5YmhmaTdaQk5WZVVMWi5WejZNa3JRZ2ppTGZUM1RkQzVhSGhDSFo5UUdrTUF6eFN1elRXSER2OXlrVUJjbXpQLlNleUowSWpvaVpHMGlMQ0p6SWpvaWFIUjBjRG92TDJ4dlkyRnNhRzl6ZERvNE1EQXdMMlJwWkdOdmJXMGlMQ0p5SWpwYlhTd2lZU0k2V3lKa2FXUmpiMjF0TDNZeUlsMTkiLCJib2R5Ijp7ImdvYWxfY29kZSI6ImlvLmF0YWxhcHJpc20uY29ubmVjdCIsImdvYWwiOiJFc3RhYmxpc2ggYSB0cnVzdCBjb25uZWN0aW9uIGJldHdlZW4gdHdvIHBlZXJzIHVzaW5nIHRoZSBwcm90b2NvbCAnaHR0cHM6Ly9hdGFsYXByaXNtLmlvL21lcmN1cnkvY29ubmVjdGlvbnMvMS4wL3JlcXVlc3QnIiwiYWNjZXB0IjpbXX19' } is successful as well.

I get the below response: { connectionId: '7e06e7a1-007e-4092-b4bf-ca483725889c', thid: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', myDid: 'did:peer:2.Ez6LSe5kkyapPVwY5FgVEc6HcvbFBKwuWQHUKkRrXRLnjQErC.Vz6MkpXFpSt5Ce6qnTJZ99ictL76GK6rb3s7BsCXXdYZpc1GG.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo5MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19', theirDid: 'did:peer:2.Ez6LShFpeUGbFu5TxspXAEFeUWV9AxVEsm7ybhfi7ZBNVeULZ.Vz6MkrQgjiLfT3TdC5aHhCHZ9QGkMAzxSuzTWHDv9ykUBcmzP.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19', role: 'Invitee', state: 'ConnectionRequestPending', invitation: { id: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', type: 'https://didcomm.org/out-of-band/2.0/invitation', from: 'did:peer:2.Ez6LShFpeUGbFu5TxspXAEFeUWV9AxVEsm7ybhfi7ZBNVeULZ.Vz6MkrQgjiLfT3TdC5aHhCHZ9QGkMAzxSuzTWHDv9ykUBcmzP.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19', invitationUrl: 'https://my.domain.com/path?_oob=eyJpZCI6IjE4MzVjNzZlLWI2YjUtNDNlYS1iOTZmLTM4ZDcxZGNhZmQ0NCIsInR5cGUiOiJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzIuMC9pbnZpdGF0aW9uIiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNoRnBlVUdiRnU1VHhzcFhBRUZlVVdWOUF4VkVzbTd5YmhmaTdaQk5WZVVMWi5WejZNa3JRZ2ppTGZUM1RkQzVhSGhDSFo5UUdrTUF6eFN1elRXSER2OXlrVUJjbXpQLlNleUowSWpvaVpHMGlMQ0p6SWpvaWFIUjBjRG92TDJ4dlkyRnNhRzl6ZERvNE1EQXdMMlJwWkdOdmJXMGlMQ0p5SWpwYlhTd2lZU0k2V3lKa2FXUmpiMjF0TDNZeUlsMTkiLCJib2R5Ijp7ImdvYWxfY29kZSI6ImlvLmF0YWxhcHJpc20uY29ubmVjdCIsImdvYWwiOiJFc3RhYmxpc2ggYSB0cnVzdCBjb25uZWN0aW9uIGJldHdlZW4gdHdvIHBlZXJzIHVzaW5nIHRoZSBwcm90b2NvbCAnaHR0cHM6Ly9hdGFsYXByaXNtLmlvL21lcmN1cnkvY29ubmVjdGlvbnMvMS4wL3JlcXVlc3QnIiwiYWNjZXB0IjpbXX19' }, createdAt: '2024-01-26T05:50:08.02406Z', updatedAt: '2024-01-26T05:50:08.463289Z', metaRetries: 5, self: '7e06e7a1-007e-4092-b4bf-ca483725889c', kind: 'Connection' }

When I try to check the status of the connection on the first agent: GET http://localhost:8081/connections/7e06e7a1-007e-4092-b4bf-ca483725889c returns not found data: { status: 404, type: 'NotFound', title: 'NotFound', detail: 'Record Id not found: 7e06e7a1-007e-4092-b4bf-ca483725889c', instance: '' }

And GET http://localhost:8081/connections/1835c76e-b6b5-43ea-b96f-38d71dcafd44 (The id here is the connection id from the first agent's response as well as the invitation id in the second agent's accept response) I get: { connectionId: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', thid: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', role: 'Inviter', state: 'InvitationGenerated', invitation: { id: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', type: 'https://didcomm.org/out-of-band/2.0/invitation', from: 'did:peer:2.Ez6LShFpeUGbFu5TxspXAEFeUWV9AxVEsm7ybhfi7ZBNVeULZ.Vz6MkrQgjiLfT3TdC5aHhCHZ9QGkMAzxSuzTWHDv9ykUBcmzP.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19', invitationUrl: 'https://my.domain.com/path?_oob=eyJpZCI6IjE4MzVjNzZlLWI2YjUtNDNlYS1iOTZmLTM4ZDcxZGNhZmQ0NCIsInR5cGUiOiJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzIuMC9pbnZpdGF0aW9uIiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNoRnBlVUdiRnU1VHhzcFhBRUZlVVdWOUF4VkVzbTd5YmhmaTdaQk5WZVVMWi5WejZNa3JRZ2ppTGZUM1RkQzVhSGhDSFo5UUdrTUF6eFN1elRXSER2OXlrVUJjbXpQLlNleUowSWpvaVpHMGlMQ0p6SWpvaWFIUjBjRG92TDJ4dlkyRnNhRzl6ZERvNE1EQXdMMlJwWkdOdmJXMGlMQ0p5SWpwYlhTd2lZU0k2V3lKa2FXUmpiMjF0TDNZeUlsMTkiLCJib2R5Ijp7ImdvYWxfY29kZSI6ImlvLmF0YWxhcHJpc20uY29ubmVjdCIsImdvYWwiOiJFc3RhYmxpc2ggYSB0cnVzdCBjb25uZWN0aW9uIGJldHdlZW4gdHdvIHBlZXJzIHVzaW5nIHRoZSBwcm90b2NvbCAnaHR0cHM6Ly9hdGFsYXByaXNtLmlvL21lcmN1cnkvY29ubmVjdGlvbnMvMS4wL3JlcXVlc3QnIiwiYWNjZXB0IjpbXX19' }, createdAt: '2024-01-26T05:48:46.46825Z', metaRetries: 5, self: '1835c76e-b6b5-43ea-b96f-38d71dcafd44', kind: 'Connection' }

Note here THE STATE REMAINS THE SAME InvitationGenerated

INVESTIGATING THE INVITATION

Decoding eyJpZCI6IjE4MzVjNzZlLWI2YjUtNDNlYS1iOTZmLTM4ZDcxZGNhZmQ0NCIsInR5cGUiOiJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzIuMC9pbnZpdGF0aW9uIiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNoRnBlVUdiRnU1VHhzcFhBRUZlVVdWOUF4VkVzbTd5YmhmaTdaQk5WZVVMWi5WejZNa3JRZ2ppTGZUM1RkQzVhSGhDSFo5UUdrTUF6eFN1elRXSER2OXlrVUJjbXpQLlNleUowSWpvaVpHMGlMQ0p6SWpvaWFIUjBjRG92TDJ4dlkyRnNhRzl6ZERvNE1EQXdMMlJwWkdOdmJXMGlMQ0p5SWpwYlhTd2lZU0k2V3lKa2FXUmpiMjF0TDNZeUlsMTkiLCJib2R5Ijp7ImdvYWxfY29kZSI6ImlvLmF0YWxhcHJpc20uY29ubmVjdCIsImdvYWwiOiJFc3RhYmxpc2ggYSB0cnVzdCBjb25uZWN0aW9uIGJldHdlZW4gdHdvIHBlZXJzIHVzaW5nIHRoZSBwcm90b2NvbCAnaHR0cHM6Ly9hdGFsYXByaXNtLmlvL21lcmN1cnkvY29ubmVjdGlvbnMvMS4wL3JlcXVlc3QnIiwiYWNjZXB0IjpbXX19

Gives: {"id":"1835c76e-b6b5-43ea-b96f-38d71dcafd44","type":"https://didcomm.org/out-of-band/2.0/invitation","from":"did:peer:2.Ez6LShFpeUGbFu5TxspXAEFeUWV9AxVEsm7ybhfi7ZBNVeULZ.Vz6MkrQgjiLfT3TdC5aHhCHZ9QGkMAzxSuzTWHDv9ykUBcmzP.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19","body":{"goal_code":"io.atalaprism.connect","goal":"Establish a trust connection between two peers using the protocol 'https://atalaprism.io/mercury/connections/1.0/request'","accept":[]}}

Decoding : eyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAwL2RpZGNvbW0iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19 from above I get : {"t":"dm","s":"http://localhost:8000/didcomm","r":[],"a":["didcomm/v2"]} which have the correct issuer agent url.

Please provide the exception or error you saw

THE STATE REMAINS THE SAME InvitationGenerated even after accepting the request

Please provide the environment you discovered this bug in

Ubuntu Linux 20.04

Anything else?

Running the agents locally with instructions on the quick start guide

bvoiturier commented 9 months ago

Hey @ndigirigijohn, thanks for the feedback!

I think the DIDComm issuer agent URL embedded in the invitation is invalid. Using localhost:8080 won't work for container-to-container communication. Using this from inside the invitee container will loopback to itself when trying to connect. You should rather use host.docker.internal as value for the DOCKERHOST env variable, which is the default unless overridden. This allows the invitee container to connect to the docker host machine, where the port 8080 of the inviter is exposed. Could you give it a try?

bvoiturier commented 9 months ago

@ndigirigijohn Sorry, it seems that the run.sh commands documented in the QSG are overriding DOCKERHOST with the wrong value via -d localhost flag:

./infrastructure/local/run.sh -n issuer -b -e ./infrastructure/local/.env-issuer -p 8000 -d localhost

Could you try spinning your agents without this flag?

ndigirigijohn commented 9 months ago

This works. The connections are now successful.

@ndigirigijohn Sorry, it seems that the run.sh commands documented in the QSG are overriding DOCKERHOST with the wrong value via -d localhost flag:

./infrastructure/local/run.sh -n issuer -b -e ./infrastructure/local/.env-issuer -p 8000 -d localhost

Could you try spinning your agents without this flag?

ndigirigijohn commented 9 months ago

Thank you for the guidance.

bvoiturier commented 9 months ago

@ndigirigijohn Is the problem solves? Can we close this issue?

ndigirigijohn commented 9 months ago

Yes, the problem is solved. However, someone following current documentation is likely to encounter the same challenge.

On Tue, Feb 6, 2024 at 6:18 PM bvoiturier @.***> wrote:

@ndigirigijohn https://github.com/ndigirigijohn Is the problem solves? Can we close this issue?

— Reply to this email directly, view it on GitHub https://github.com/hyperledger-labs/open-enterprise-agent/issues/866#issuecomment-1930028456, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVNNDFGZSZ7ZNY7TI3LY3ITYSJCTVAVCNFSM6AAAAABCLWQSBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZQGAZDQNBVGY . You are receiving this because you were mentioned.Message ID: @.***>

bvoiturier commented 9 months ago

Thanks for the feedback, John. Issue fixed by https://github.com/input-output-hk/atala-prism-docs/pull/77