gRPC with UE4

Hi,

I’m new to gRPC and UE C++. I’m trying to create a gRPC server on UE4 and connect it to a remote client.

I first tried GitHub - adamrehn/ue4-grpc-demo: Dockerised Unreal Engine 4 microservice demo using gRPC without the docker part and was able to make it work with small modifications. Now, I’m trying to port the GrpcServiceImp.h & it’s .cpp part into a Plugin. However, once ported to a plugin, engine is crashing when I try to send commands from a python client. The trace was something like this



<CALLSTACK START>
grpc_impl::internal::RpcMethodHandler<PawnMovementDemo::Service, Direction, Empty>::D
https:\/\/forums.unrealengine.com\/core\/image\/gif;base64
​eserialize(grpc_call*, grpc_byte_buffer*, grpc::Status*, void**) Address = 0x174ee7926 ~/.local/include/grpcpp/impl/codegen/method_handler_impl.h, line 99] [in UE4Editor-MyPlugin-0021.dylib]
grpc_impl::Server::SyncRequest::CallData::Run(std::__1::shared_ptr<grpc_impl::Server::GlobalCallbacks> const&, bool) Address = 0x1753e9966 (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc_impl::Server::SyncRequestThreadManager::D
https:\/\/forums.unrealengine.com\/core\/image\/gif;base64
​oWork(void*, bool, bool) Address = 0x1753e880b (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc::ThreadManager::MainWorkLoop() Address = 0x175424101 (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc::ThreadManager::WorkerThread::Run() Address = 0x175423dec (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc::ThreadManager::WorkerThread::WorkerThread(grpc::ThreadManager*)::$_0::o
https:\/\/forums.unrealengine.com\/core\/image\/gif;base64
​perator()(void*) const Address = 0x17542507c (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc::ThreadManager::WorkerThread::WorkerThread(grpc::ThreadManager*)::$_0::__invoke(void*) Address = 0x175425055 (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc_core::(
https:\/\/forums.unrealengine.com\/core\/image\/gif;base64
​perator()(void*) const Address = 0x1759537ef (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
grpc_core::(
https:\/\/forums.unrealengine.com\/core\/image\/gif;base64
​anonymous namespace)::ThreadInternalsPosix::ThreadInternalsPosix(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)::'lambda'(void*)::__invoke(void*) Address = 0x1759536e5 (filename not found) [in UE4Editor-ConanUE4-7613.dylib]
_pthread_start Address = 0x7fff73926109 (filename not found) [in libsystem_pthread.dylib]
thread_start Address = 0x7fff73921b8b (filename not found) [in libsystem_pthread.dylib]
<CALLSTACK END>


Initially I had the gRPC dependencies in my project’s .build.cs. Now, I’ve included the same dependencies in the Plugin’s .build.cs and removed it from the project’s .build.cs. This is static linkage of gRPC libraries.

The .uplugin part contains



"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "",
"Description": "",
"Category": "Other",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": 
{
"Name": "MyPlugin",
"Type": "Runtime",
"LoadingPhase": "Default"
}
]


and I’ve added the dependency of the Plugin module in the project’s .build.cs.

I’m creating the server during BeginPlay(). Also, I tried different LoadingPhase for the Plugin module - PreDefault, Default, PostDefault and none of them worked.

The functionality is failing not when I start the game, but when I send my first message from the client. For me, it looks like some thread issue - one thread is not able to communicate to another? I’m not sure. I’m unable to understand what is causing this issue. Any help that could direct me towards potential problems would be helpful!

Thanks in advance!

Cheers!

3 Likes

hello,Solved?