Replies: 1 comment
-
For legibility, could you edit your post to use code-formatting throughout? I'm a little confused by the code you posted. What is the consumerProxy = runtime1->buildProxyv1::wrapper::ConsumerProxy("local", "wapperConsumer"); Also, you should have a connection name into the As for your polling, // Poll until proxy becomes available
while (!consumerProxy->isAvailable()) {
printf("Trail: %d ConsumerProxy service unavailable, retrying\n", count);
++count;
usleep(100000); // Sleep for 100ms (adjust as needed)
}
// Proxy is available, update status flag
bConsumerProxyAvailable.store(true); I recommend deleting all that. It doesn't do anything for your app. Other than There's also no point (typically) for polling for the availability - your subscriptions will function when the service is available and won't when it's not. There is an
For your runtime, std::shared_ptrCommonAPI::Runtime runtime1 = CommonAPI::Runtime::get(); Why auto runtime = CommonAPI::Runtime::get(); I don't think this is doing what you expect: std::shared_ptr consumerStub = std::make_shared(); (does this compile?) auto consumerStub = std::make_shared<ConsumerStub>(); I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I'm new to using CommonAPI. I apologize if this isn't the appropriate platform for questions related to CommonAPI.
I'm encountering an issue with my proxy setup where isAvailable() always returns false despite the stub being up and running. Below is the setup code for the consumer proxy:
void ConsumerCapiProxy::setup() {
int count = 1;
InfoLog("ConsumerCapiProxy setup");
// Get the CommonAPI runtime
std::shared_ptrCommonAPI::Runtime runtime1 = CommonAPI::Runtime::get();
if (runtime1 != nullptr) {
// Attempt to build the proxy
consumerProxy = runtime1->buildProxyv1::wrapper::ConsumerProxy(
"local", "wrapper.Consumer");
if (consumerProxy != nullptr) {
// Subscribe to proxy status events
consumerProxy->getProxyStatusEvent().subscribe(onProxyStatusEvent);
} else {
ErrorLog("ConsumerCapiProxy: CommonAPI Runtime cannot be null");
}
}
<<<
and here is the Stub code:
<<<
void ConsumerCapiStub::serviceStart() {
bool serviceRegistered = false;
DLT_LOG(CRCC, DLT_LOG_INFO, DLT_STRING("ConsumerCapiStub() setup"));
std::shared_ptrCommonAPI::Runtime runtime1 = CommonAPI::Runtime::get();
if (runtime1 != nullptr) {
DLT_LOG(CRCC, DLT_LOG_INFO, DLT_STRING("Success to initialize CommonAPI runtime."));
if(nullptr == consumerStub.get()) {
std::shared_ptr consumerStub = std::make_shared();
DLT_LOG(CRCC, DLT_LOG_INFO, DLT_STRING("Allocate consumerStub"));
}
if(nullptr != consumerStub.get()) {
serviceRegistered = runtime1->registerService("local", "wrapper.Consumer", consumerStub);
if(serviceRegistered) {
DLT_LOG(CRCC, DLT_LOG_INFO, DLT_STRING("Registration Success: ConsumerapiInterface() connected to server"));
}
else
DLT_LOG(CRCC, DLT_LOG_ERROR, DLT_STRING("register error"));
} else
DLT_LOG(CRCC, DLT_LOG_ERROR, DLT_STRING("consumerStub is nullptr"));
}
else
DLT_LOG(CRCC, DLT_LOG_ERROR, DLT_STRING("Failed to initialize CommonAPI runtime."));
}
I've confirmed that the serviceID and InstanceID are correctly provided from the FIDL files. Despite successful registration, the connection between the proxy and stub is not established. Could you please assist in diagnosing potential issues that might be causing the proxy service to remain unavailable? What files I need to check (for ex: .fidl, .fdepl, .ini or binding code and skeleton code) to understand where the issue is happening ?
Your insights and assistance would be greatly appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions