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

Error: This vat only supports a bootstrap interface, not the old Cap'n-Proto-0.4-style named exports #223

Closed
LasseBlaauwbroek opened this issue Feb 16, 2021 · 4 comments

Comments

@LasseBlaauwbroek
Copy link
Contributor

I'm trying to use capnp to connect an Ocaml process to a Python process. I have successfully followed the 'echo'-tutorial of capnp-rpc, getting an Ocaml client to talk to an Ocaml server. I created a similar setup in Python (having two python processes talk to each other). Now I wish to run the echo-server in a Python process and use an Ocaml client to connect to it. However, I am met with the following error:

atal error: exception (Failure
  "Error calling field(2) -> Failed: This vat only supports a bootstrap interface, not the old Cap'n-Proto-0.4-style named exports.(Echo.ping): Failed: This vat only supports a bootstrap interface, not the old Cap'n-Proto-0.4-style named exports.")

This error seems to originate from the C++ code that Python binds to:
https://github.com/capnproto/capnproto/blob/3f01eac812af3ca863d55981423fb90c08be0809/c%2B%2B/src/capnp/rpc.c%2B%2B#L2579-L2580

Am I doing something wrong while calling for the service, or is the implementation still using these 0.4-style named exports? Below is the code to reproduce:

@0xafda4797418def92;

interface Echo {
  ping @0 (msg :Text) -> (reply :Text);
}
open Lwt.Infix
open Capnp_rpc_lwt

let () =
  Logs.set_level (Some Logs.Warning);
  Logs.set_reporter (Logs_fmt.reporter ())

let run_client service =
  Echo_client.ping service "foo" >>= fun reply ->
  Fmt.pr "Got reply %S@." reply;
  Lwt.return_unit

let () =
  Lwt_main.run begin
    let client_vat = Capnp_rpc_unix.client_only_vat () in
    let sr = Capnp_rpc_unix.Vat.import_exn client_vat @@ Uri.of_string "capnp://insecure@localhost:5001" in
    Sturdy_ref.with_cap_exn sr run_client
  end
#!/usr/bin/env python3

import argparse
import capnp
import time

import echo_api_capnp

class EchoImpl(echo_api_capnp.Echo.Server):

    def ping(self, msg, _context):
        print(msg)
        print(_context)
        return "boe"


def parse_args():
    parser = argparse.ArgumentParser(usage='''Runs the server bound to the\
given address/port ADDRESS may be '*' to bind to all local addresses.\
:PORT may be omitted to choose a port automatically. ''')

    parser.add_argument("address", help="ADDRESS[:PORT]")

    return parser.parse_args()


def main():
    address = parse_args().address

    server = capnp.TwoPartyServer(address, bootstrap=EchoImpl())
    while True:
        server.poll_once()
        time.sleep(0.001)


if __name__ == '__main__':
    main()
@talex5
Copy link
Contributor

talex5 commented Feb 16, 2021

Yes, it uses the original (simpler) bootstrapping scheme. I didn't know anyone was using the newer one (I thought it might have been abandoned).

I think you probably just need to use restorer instead of bootstrap in the Python server.

Possibly the OCaml code should skip setting the ID if it's the empty string so it can support either scheme.

Schema.BuilderOps.write_string (Bootstrap.deprecated_object_id_get boot) object_id;

@LasseBlaauwbroek
Copy link
Contributor Author

Thanks for the quick reply. Unfortunately, it looks like the workaround you suggested will not work, because the restorer named argument was removed from the python implementation in 2019 (even though the documentation still mentions it): capnproto/pycapnp@f6dd08d#diff-17d3a2bf99cbe0f9aeebce3362e3e7c5ce9a732f43c205cee6c00fee54a09790L2417

Do you have any ideas for other workarounds? Thanks.

@talex5
Copy link
Contributor

talex5 commented Feb 17, 2021

Did the other change I suggested work? i.e. don't set the object_id if it's the empty string.

@LasseBlaauwbroek
Copy link
Contributor Author

Ah sorry, I thought that was more of a meta-comment, not something for me to try. I tried it now, and I can indeed confirm it works. See PR #224.

@talex5 talex5 closed this as completed in 50d4371 Feb 18, 2021
talex5 added a commit that referenced this issue Feb 18, 2021
Fix #223 by skipping the setting of object_id if it is empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants