credo-ts icon indicating copy to clipboard operation
credo-ts copied to clipboard

'Socket is closed' when agent has no endpoint and uses WS

Open genaris opened this issue 3 years ago • 0 comments

After the fix #946, I noticed a problem when an agent does not have an endpoint (e.g. mobile agent not bound to a mediator yet) and uses WebSocket as outbound transport.

As expected, the socket is being closed when DID Exchange is completed, but if another message (e.g. request a credential or request mediation) is immediately sent to the newly created connection, message sender will fail with an 'Socket is closed' error. It seems like the socket is still opened when it checks if a session is opened, but it is effectively closed when the transporter calls ws.send() method.

If I wait some time before sending the next message (1 second or so) it works fine consistently, so that makes me think that it's just a synchronization issue in the WebSocket session handling.

genaris avatar Sep 10 '22 23:09 genaris