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

Unix jsonrpc server paniced when handling connection #6

Open
weiyuhang2011 opened this issue Jul 4, 2024 · 3 comments
Open

Unix jsonrpc server paniced when handling connection #6

weiyuhang2011 opened this issue Jul 4, 2024 · 3 comments
Labels
bug Something isn't working jsonrpc

Comments

@weiyuhang2011
Copy link

I tried to build a jsonrpc server using unix socket. But it seems like the server throw panic on handling connection.

This is my server code:

fn start_run() {
    use karyon_core::async_util::sleep;
    use karyon_jsonrpc::Server;
    use rpc::Calc;
    use std::sync::Arc;
    use std::time::Duration;
    smol::block_on(async {
        let calc = Arc::new(Calc {});

        // Creates a new server
        let server = Server::builder("unix:///tmp/karyon-test.sock")
            .expect("Create a new server builder")
            .service(calc.clone())
            .pubsub_service(calc)
            .build()
            .await
            .expect("Build a new server");

        // Start the server
        server.start();

        sleep(Duration::MAX).await;
    });
}

I use nc -U /tmp/karyon-test.sock to test the server. Below is the server log:

2024-07-04T09:17:01Z INFO  karyon_jsonrpc::server] RPC server listens to the endpoint: unix://tmp/karyon-test.sock
thread 'smol-executor' panicked at 'get peer endpoint: IO(Kind(AddrNotAvailable))', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/karyon_jsonrpc-0.1.5/src/server/mod.rs:110:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@hozan23
Copy link
Member

hozan23 commented Jul 4, 2024

Hello @weiyuhang2011, I just patched a fix for this issue. You can use the karyon_jsonrpc from the master branch until I deploy the new changes and fixes to crates.io.

@hozan23 hozan23 added bug Something isn't working jsonrpc labels Jul 4, 2024
@weiyuhang2011
Copy link
Author

Thanks for your quick response. But I dont't understand why it can't connect to the server. I think I used the correct socket address.

@hozan23
Copy link
Member

hozan23 commented Jul 4, 2024

Hey @weiyuhang2011, yes, the address is correct. You can also just use the path: Server::builder("unix:/tmp/karyon-test.sock"). However, the issue was due to a bug in handling new connections from the server side. It was trying to resolve the client address for debugging.

You can check the patch here: 6c65232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jsonrpc
Projects
None yet
Development

No branches or pull requests

2 participants