Skip to content
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

JSON RPC over IPC should support multiple simultaneous clients #8257

Open
mralj opened this issue Feb 24, 2025 · 0 comments
Open

JSON RPC over IPC should support multiple simultaneous clients #8257

mralj opened this issue Feb 24, 2025 · 0 comments

Comments

@mralj
Copy link
Contributor

mralj commented Feb 24, 2025

Is your feature request related to a problem? Please describe.
The way the JsonRpcIpcRunner is implemented now doesn't allow multiple simultaneous clients to be connected. This is because in accept connection loop we do the following

while (true)
{
    if (_logger.IsInfo) _logger.Info("Waiting for an IPC connection...");

    Socket socket = await _server.AcceptAsync(cancellationToken);

    socket.ReceiveTimeout = _jsonRpcConfig.Timeout;
    socket.SendTimeout = _jsonRpcConfig.Timeout;

    using JsonRpcSocketsClient<IpcSocketMessageStream>? socketsClient = new(
        string.Empty,
        new IpcSocketMessageStream(socket),
        RpcEndpoint.IPC,
        _jsonRpcProcessor,
        _jsonRpcLocalStats,
        _jsonSerializer,
        maxBatchResponseBodySize: _jsonRpcConfig.MaxBatchResponseBodySize);

    await socketsClient.ReceiveLoopAsync();
}

The issue is the line await socketsClient.ReceiveLoopAsync(); because as long as we are serving one client, we cannot accept others.

Describe the solution you'd like
To be able to use JSON RPC over IPC/UnixDomainSockets with multiple clients simultaneously.

Additional context
Additionally the way this whole section is written, more specifically thanks to this call to Dispose if the client Disconnects in erroneous way the whole IPC is shut down and no more clients are able to connect unless the node is restarted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant