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
incompatible code generation for flatbuffer grpc service with c++ #5836
Comments
What are the errors? Can you try with FlatBuffers 1.12 or master? |
error: 'grpc::ClientContext' has not been declared |
yes i tried with grpc master and flatbuffer master grpc and flatbuffers are installed manually inside /usr/local/include dir cmake_minimum_required(VERSION 3.15) these are the following commands i used to install grpc |
Hmm, that's a pretty core GRPC class, and the current docs still refer to it, so I don't think they renamed it or something.. does the test code you include the generated code in have a Does this compile? https://github.com/google/flatbuffers/tree/master/grpc/samples/greeter |
no it does not build but the error has changed In file included from /home/pavan/CLionProjects/episilia-query/lib/src/log_query_service.grpc.fb.cc:6:0: |
solved it by removing those class declarations but still facing the error |
i have added |
does this fix it? #5843 |
my issue is with c++ server code generation will check it although thank you @aardappel |
Having the same error here, following the flatbuffers gRPC tutorial code (greeter example) verbatim. |
does this fix it? #5843 nope it did not @aardappel but it fixed for swift but c++ is not yet supported some namespace changes have been occurred in c++ grpc which results in some of the compile error with some classes not declared in scope |
i would suggest you to use grpc 16.1.1 which is last working version that is compatible with flatc grpc generated code |
Okay! thanks, will try :) |
flatbuffers project currently depends on an old version of GRPC library and has known issues working with the latest version (issue #5836). Therefore, a patch file is created and put under bazel/ directory before supporting the latest GRPC version.
We've run into this incompatibility with recent gRPC versions as well. We tried using VCPKG to install and build both flatbuffers and gRPC, and they are incompatible. I noticed the reference above to 1.16.1 (I'm assuming 16.1.1 is a typo), but the bazel file refers to 1.15.1, what would be the correct version of gRPC to use with flatbuffers? |
Hello everyone! I was able to successfully compile and run the greeter example (and few of self custom schemas) using the 1. Modification in generated schema (greeter.grpc.fb.h for example)Before (originally generated code from
|
@yaoshengzhe (who is currently fixing some of the gRPC integration). |
Having the same issues. @aardappel @yaoshengzhe I am currently trying to use gRPC with flatbuffers (C++) but looks like support is broken after gRPC 1.16.1 (discussed above). I am very new to flatbuffers, but can try to help if needed. |
I was also having the same issue and when trying with 1.16.0 and compiling the example I get below error: /usr/bin/ld: /tmp/ccLp62cl.o: in function ... Is it also related to the versions? I found this issue #5099 but I am not able to make it work either |
Also, is the intent of flatbuffers to give support to gRPC? I am thinking on using them on a long term project but this compatibility problems make me think it could make the maintenance hard in the future. |
@joseprupi the way it currently works (we share the code generator between FlatBuffers and upstream Protobuf) is very fragile, any changes in upstream code can break us. But there really also is no easier way to keep up to date with gRPC. Usually these changes are small and easy to fix, but for some reason no-one on here has been able to make a PR for them. @yaoshengzhe ? |
Thanks @aardappel . I will try to take a look to it but sincerely I don't know where to start so some tips would be appreciated :) |
@joseprupi I'd start by trying to build the C++ test in https://github.com/google/flatbuffers/tree/master/grpc with the latest version of gRPC, and seeing what errors come out. They should ideally all be solved by changes in the FlatBuffers generators or runtime code. You may have to update the files in https://github.com/google/flatbuffers/tree/master/grpc/src/compiler with newer versions copied from gRPC. Runtime changes may have to be made in https://github.com/google/flatbuffers/blob/master/include/flatbuffers/grpc.h |
Hello @aardappel I have created this PR #6143 if someone can take a look to it |
@aardappel I've tried to solve some o the issues you mentioned and closed the PR. As far as I see there is no way to access the byte_buffer without copy and reading the comments it does not seem is going to happen soon. |
@joseprupi wow, surprised they apparently care more about their API design than zero-copy. Well, maybe that means we should put in your workaround until they fix their stuff... with a big warning sign? That way at least people can work with it. |
@aardappel Well I won't share my opinion but that two projects like this from the same company don't work together is weird :) For me the solution is modifying grpc to make it work as I think is a good stack but I will try to spend some more time with the PR to at least have an official way to use it if. Also I think this should be reflected in the README and probably this blog post https://grpc.io/blog/grpc-flatbuffers/, for me is the first entry when searching for flatbuffers+grpc in google and can be confusing. |
I have to say I'm a bit disappointed of the attitude of the gRPC team in this particular case, breaking a working feature in a related and supposedly supported project and begin dogmatic about correcting it is not very... agile 👎 Especially considering that the API is semi-official in the sense that unit tests use it. I'm guessing the gprc modification you are talking about @joseprupi, is the comment made here?grpc/grpc#20594 (comment) Thanks for the PR btw! |
Yes, I agree that is weird and unfortunate. In large companies, different parts don't always work together as you'd expect. And are not equally supported. Agree that be great if it could be fixed in gRPC. I can ping some people but wouldn't get my hopes up. |
@aardappel I hope you did not take it in a bad way, it was just an observation as to me seems clear that grpc would want to have a non copy version of flatbuffers but those are your processes and obviously the interests are different. And btw thank you for your work with flatbuffers. @thomas-t1 if I keep going with this stack I will try to expose the byte_buffer with the fewer lines of code possible so maybe something like this grpc/grpc#17603. It seems there have been several attempts to solve this problem before. |
flatbuffers project currently depends on an old version of GRPC library and has known issues working with the latest version (issue google#5836). Therefore, a patch file is created and put under bazel/ directory before supporting the latest GRPC version.
@aardappel cant we just make them as a plugin to proto compiler which generates grpc files for flatbuffer rather then flatc taking it |
@pavanbadugu that would require FlatBuffers users to translate their .fbs schema to .proto. Then it would require us to write this plugin, and maintain it, because now we have the reverse problem: FlatBuffer changes breaking this plugin. |
Yeah, this is annoying - I have tried a few times to upgrade GRPC version to latest, but failed every time, the current working integration for me is this (flatbuffers v1.12.0 + grpc v1.20.0) with one single manual fix: https://github.com/varchar-io/nebula/blob/master/ext/Grpc_Ext.cmake#L62-L74 just sharing this working but ugly trick if you may find it useful. This also means it has potential integration problems with integrating more library such as google-cloud-cpp who depends on grpc too, because of this, I even can't use VCPKG to manage them (flatbuffers, grpc), I wish this community (Google) can fix this scenario and maintain a good integration across these libraries. Thanks! |
any updates here? I'm on FlatBuffers 1.20 and grace 1.37.1 and the problem still persists. I would be nice to be able to use gRPC with FlatBuffers.... |
created a fbs file with a grpc service and executed
flatc --cpp --grpc log_query_service.fbs got the file generated but the header file and the cc file has compile time errors
grpc 1.27.3
flatbuffer 1.11.0
please let me know what version to use to resolve this issue
thank you
The text was updated successfully, but these errors were encountered: