Skip to content

Make it possible to have stateful connections #60

@Frando

Description

@Frando

A typical usecase involves authenticating to a remote server.

I first thought this would be easy enough: See this example https://github.com/n0-computer/irpc/blob/main/irpc-iroh/examples/auth.rs

There's a Auth message that contains whatever authentication token you are using. The server expects the first message on a connection to be that message, and aborts the connection if not or if the token doesn't verify. From the server side, all is good.

On the client side however, it seems to be fine to just issue an Auth rpc call when constructing a client. However, it is not: the RemoteConnection impls for both irpc over quic and irpc-iroh support reconnects-on-demand: If the previous connection was aborted by the server in-between (e.g. because the server was restarted), irpc will reconnect to the server with the same args (alpn and node addr) than in the initial connection. The request submitted by the application will then be sent on the new connection - which will fail, because the server expects an Auth message as the first message on each connection.

It is currently completely invisible to the irpc::Client and application code if and when such reconnections happend, therefore there's no way currently to "send an Auth request first whenever a reconnect happens".

Fixing this is quite important to me, I have multiple uses of irpc that would need this. The only alternative currently is to send a token with each and every request, which is wasteful and cumbersome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions