plugin gets stuck while loading
AnsweredI am trying to call a python API while loading plugin, For that I used following code
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int starter(){
std::cout<<"pinging..............................................................";
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8000/init");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
std::cout<<readBuffer;
}
auto j = json::parse(readBuffer);
if (j["folder"]){
std::cout<<"Image folder is created";
}
std::cout<<j["name"];
return 0;
}
int init_caller = starter();
/**
* @param deviceInfo Various information about the related device, such as its id, vendor, model,
* etc.
*/
DeviceAgent::DeviceAgent(const nx::sdk::IDeviceInfo* deviceInfo):
// Call the DeviceAgent helper class constructor telling it to verbosely report to stderr.
ConsumingDeviceAgent(deviceInfo, /*enableOutput*/ true)
{
cameraId = deviceInfo->id();
}
starter function is called but it stuck at res = curl_easy_perform(curl); After a few minutes plugin throws
>>> ASSERTION FAILED: /home/jenkins/build-0-linux-x64-vms_4.1/nx_vms/vms/server/nx_vms_server/src/media_server_process.cpp:1202 (false) Server was unable to stop within 100s
I am not sure why it's not working. The above code works as I expected If i execute that as separate cpp file.
Traceback log:
2020-05-08 10:37:30.440 4757 INFO START: ================================================================================
2020-05-08 10:37:30.441 4757 INFO START: Network Optix MetaVMS Media Server started, version: 4.1.0.30731, revision: 457d4da9daf1
2020-05-08 10:37:30.441 4757 INFO START: Binary path: /opt/networkoptix-metavms/mediaserver/bin/mediaserver-bin
2020-05-08 10:37:30.441 4757 INFO START: Log level: info
2020-05-08 10:37:30.441 4757 INFO START: Log file size: 10M, backup count: 25, file: /opt/networkoptix-metavms/mediaserver/var/log/log_file.log
2020-05-08 10:37:30.441 4757 INFO START: Mutex implementation: qt
2020-05-08 10:37:30.442 4757 INFO nx::vms::server::RootFileSystem: Root tool enabled: false
2020-05-08 10:37:30.442 4757 WARNING nx::vms::server::nvr::hanwha: Unable to get board id, result -1
2020-05-08 10:37:30.446 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libaxis_analytics_plugin.so]
2020-05-08 10:37:30.447 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libaxis_analytics_plugin.so] (main interface nx_sdk_analytics_IPlugin)
2020-05-08 10:37:30.447 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libdahua_analytics_plugin.so]
2020-05-08 10:37:30.447 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libdahua_analytics_plugin.so] (main interface nx_sdk_analytics_IPlugin)
2020-05-08 10:37:30.448 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libdw_mtt_analytics_plugin.so]
2020-05-08 10:37:30.448 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libdw_mtt_analytics_plugin.so] (main interface nx_sdk_analytics_IPlugin)
2020-05-08 10:37:30.448 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libgeneric_multicast_plugin.so]
2020-05-08 10:37:30.449 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libgeneric_multicast_plugin.so] (old SDK, main interface nxpl_Plugin)
2020-05-08 10:37:30.449 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libgeneric_rtsp_plugin.so]
2020-05-08 10:37:30.449 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libgeneric_rtsp_plugin.so] (old SDK, main interface nxpl_Plugin)
2020-05-08 10:37:30.449 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libhanwha_analytics_plugin.so]
2020-05-08 10:37:30.450 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libhanwha_analytics_plugin.so] (main interface nx_sdk_analytics_IPlugin)
2020-05-08 10:37:30.451 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libhikvision_analytics_plugin.so]
2020-05-08 10:37:30.451 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libhikvision_analytics_plugin.so] (main interface nx_sdk_analytics_IPlugin)
2020-05-08 10:37:30.451 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libmjpeg_link_plugin.so]
2020-05-08 10:37:30.452 4757 INFO PluginManager(0x7fd49405d370): Loaded Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libmjpeg_link_plugin.so] (old SDK, main interface nxpl_Plugin2)
2020-05-08 10:37:30.452 4757 INFO PluginManager(0x7fd49405d370): Considering to load Server plugin [/opt/networkoptix-metavms/mediaserver/bin/plugins/libsample_analytics_plugin.so]
2020-05-08 10:38:13.164 4749 WARNING QMessageLogContext(0x562d44ad1a78): Stopping server
2020-05-08 10:39:53.164 4749 ERROR CRASH: ASSERTION FAILED: /home/jenkins/build-0-linux-x64-vms_4.1/nx_vms/vms/server/nx_vms_server/src/media_server_process.cpp:1202 (false) Server was unable to stop within 100s
-
Hi @...,
In your case the hanging function belongs to a third-party library, so there is a high probability that there's something wrong with your call to curl_easy_perform. At the moment it is hardly possible for us to tell why doesn't the issue reproduce when you run the code separately from the plugin. Probably, you'll find this thread on StackOverflow useful when debugging: https://stackoverflow.com/questions/50573092/libcurl-curl-easy-perform-blocks-unless-curlopt-readfunction-is-set
If that does not help and the cause of the issue remains unclear, the only thing I can suggest you is to share your plugin library and source code as well as your standalone backend application with us, if you are Okay with it, of course.
0 -
Hello Maxim,
I have implemented the task using boost lib. Now the issue is resolved. thanks for the info.
0 -
Hi Mohamed,
These are good news! Good luck with your further development, don't hesitate to ask us should you have any questions.
0
Please sign in to leave a comment.
Comments
3 comments