I would like to write and read data from the DataLayer and also provide a user interface through the browser for configuration of the app.
I'm using the following HTTP Library: https://github.com/yhirose/cpp-httplib
Now I face the following problem: When creating a datalayer node and including the httplib.h file, the snap app crashes.
The minimal example I could recreate, was to use the datalayer.register.node sample and just put a
at the top of the main.cpp file (and also put the httplib.h file next to the main.cpp). Building the sample works, but when the app starts it crashes (seg faults) directly.
I did not put any additional code, only the include. All classes and methods are behind namespaces. I also tried to rename all defines to be unique, but the crash did not change. The crash occurs during the start() of the provider.
Using the split.py script from the github project, I could split the httplib.h file into a httplib.cc and httplib.h, than I created a shared libary. Now when I build the project and link against the shared library (and also starting a http server serving a simple site), the app crashes when an access over http occurs. With this setup I also saw the message, that the segfault occured in the libcomm_datalayer.so:
appname: segfault at 15 ip 00007f5d16e98184 sp 00007f5d06ffbee0 error 4 in libcomm_datalayer.so[7f5d16d97000+25f000]
Including the new httplib.h file (after splitting it with split.py) worked fine, so the includes and defines from httplib.h are not the culprit.
Do I need to configure the sockets from the httplib library in some specific way to not to conflict with the datalayer sockets?
I tried to reproduce your errors but could not in my case (withyour minimal example) everthing works just fine. See my snaps attached.
Which version of the system (please make a system report via "About -> Generate Report") and the SDK are you using?
Thank you very much!
From your snap I saw that you are using the IPC connection (DL_IPC_AUTO) instead of "tcp://...". With DL_IPC_AUTO everything seems to work fine. But with "tcp://..." the above crashes occure.
Thus I will be using DL_IPC_AUTO.
I'm using the SDK Version 1.8.0 RM21.07 and CtrlX Works 1.8.1. Do you still need the system report?
I could have a look in the log files that are part of the system report what the messages out of the snap are. But as it is working at your side it will be not that relevant then.
I will do the tests with tcp connection also and come back here later on.
Please make sure when using the tcp connection that user name and password have to fit to your controller. Some time we see that this is changed in the user management but not in the connection settings snaps. EDIT: Same for the IP address of the control.
I could now also reproduce a crash when using the TCP connection and adding the httlib.h to the project. We are now further investigating this issue. Thanks for mentioning.
The problem of crashing application when using the httplib.h will be fixed in next SDK version 1.10 coming up with RM21.07 end of July.