Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    nicraMarcin
    @nicraMarcin

    This is very strange behaviour.

    Oct 23 17:22:12 marcin-huawei systemd[1]: nmsapi.service: Supervising process 47157 which is not our child. We'll most likely not notice when it exits.
    Oct 23 17:22:12 marcin-huawei /usr/bin/nmsapi[47157]: Starting nmsapi
    Oct 23 17:22:12 marcin-huawei /usr/bin/nmsapi[47157]: INFO (NmsComponent): Loading configuration from /etc/nms/nms.config.json
    Oct 23 17:22:12 marcin-huawei /usr/bin/nmsapi[47157]: INFO (CreateServerConnectionProvider): Server is configured with SSL and accepts only https://
    Oct 23 17:22:12 marcin-huawei /usr/bin/nmsapi[47157]: INFO (NMS): Server running on port 8443
    Oct 23 17:22:12 marcin-huawei /usr/bin/nmsapi[47157]: INFO (main): Running daemonized server
    Oct 23 17:22:12 marcin-huawei /usr/bin/nmsapi[47157]: INFO (main): Server NMS is running
    Oct 23 17:22:15 marcin-huawei /usr/bin/nmsapi[47157]: Debug: received SIGTERM signal
    Oct 23 17:22:15 marcin-huawei /usr/bin/nmsapi[47157]: INFO (main): Server stopped
    Oct 23 17:22:15 marcin-huawei systemd[1]: nmsapi.service: Killing process 47157 (nmsapi) with signal SIGKILL.
    Oct 23 17:22:15 marcin-huawei /usr/bin/nmsapi[47157]: Objects count: 0, ObjectsCreated: 0
    Oct 23 17:22:15 marcin-huawei systemd[1]: nmsapi.service: Killing process 47157 (nmsapi) with signal SIGKILL.
    Oct 23 17:22:15 marcin-huawei systemd[1]: nmsapi.service: Succeeded.
    
    
    Oct 23 17:22:27 marcin-huawei systemd[1]: nmsapi.service: Supervising process 47191 which is not our child. We'll most likely not notice when it exits.
    Oct 23 17:22:27 marcin-huawei /usr/bin/nmsapi[47191]: Starting nmsapi
    Oct 23 17:22:27 marcin-huawei /usr/bin/nmsapi[47191]: INFO (NmsComponent): Loading configuration from /etc/nms/nms.config.json
    Oct 23 17:22:27 marcin-huawei /usr/bin/nmsapi[47191]: INFO (CreateServerConnectionProvider): Server is configured with SSL and accepts only https://
    Oct 23 17:22:27 marcin-huawei /usr/bin/nmsapi[47191]: INFO (NMS): Server running on port 8443
    Oct 23 17:22:27 marcin-huawei /usr/bin/nmsapi[47191]: INFO (main): Running daemonized server
    Oct 23 17:22:27 marcin-huawei /usr/bin/nmsapi[47191]: INFO (main): Server NMS is running
    Oct 23 17:22:32 marcin-huawei /usr/bin/nmsapi[47191]: Debug: received SIGTERM signal
    Oct 23 17:22:32 marcin-huawei /usr/bin/nmsapi[47191]: INFO (main): Server stopped
    Oct 23 17:22:32 marcin-huawei systemd[1]: nmsapi.service: Killing process 47191 (nmsapi) with signal SIGKILL.
    Oct 23 17:22:32 marcin-huawei /usr/bin/nmsapi[47191]: Objects count: 0, ObjectsCreated: 0
    Oct 23 17:22:32 marcin-huawei systemd[1]: nmsapi.service: Killing process 47191 (nmsapi) with signal SIGKILL.
    Oct 23 17:22:32 marcin-huawei systemd[1]: nmsapi.service: Succeeded.
    
    
    Oct 23 17:22:44 marcin-huawei /usr/bin/nmsapi[47203]: Starting nmsapi
    Oct 23 17:22:44 marcin-huawei /usr/bin/nmsapi[47203]: INFO (NmsComponent): Loading configuration from /etc/nms/nms.config.json
    Oct 23 17:22:44 marcin-huawei /usr/bin/nmsapi[47203]: INFO (CreateServerConnectionProvider): Server is configured with SSL and accepts only https://
    Oct 23 17:22:44 marcin-huawei /usr/bin/nmsapi[47203]: INFO (NMS): Server running on port 8443
    Oct 23 17:22:44 marcin-huawei /usr/bin/nmsapi[47203]: INFO (main): Running daemonized server
    Oct 23 17:22:44 marcin-huawei /usr/bin/nmsapi[47203]: INFO (main): Server NMS is running
    Oct 23 17:22:48 marcin-huawei /usr/bin/nmsapi[47203]: Debug: received SIGTERM signal
    Oct 23 17:22:48 marcin-huawei /usr/bin/nmsapi[47203]: INFO (main): Server stopped
    Oct 23 17:22:48 marcin-huawei /usr/bin/nmsapi[47203]: Objects count: 0, ObjectsCreated: 0
    Oct 23 17:22:48 marcin-huawei systemd[1]: nmsapi.service: Main process exited, code=dumped, status=6/ABRT
    Oct 23 17:22:48 marcin-huawei systemd[1]: nmsapi.service: Failed with result 'core-dump'

    I started and stoped three times and twice exited normally but started with Supervising process 47191 which is not our child. We'll most likely not notice when it exits. and once started well but exited with error Main process exited, code=dumped, status=6/ABRT

    but I have this error also :(
    systemd[1]: nmsapi.service: Can't open PID file /run/nmsapi.pid (yet?) after start: Operation not permitted
    oat++
    @oatpp_io_twitter

    Hey @nicraMarcin ,

    I think it's better to check Linux docs, you might be missing something.
    In any case, it doesn't look like to have anything with oatpp at this point

    nicraMarcin
    @nicraMarcin
    Ok, and what about my daemonizig is it correct?
    nicraMarcin
    @nicraMarcin

    @oatpp_io_twitter this isn't linux issue. I've written simple daemon with systemd

    [Unit]
    Description=Network Management System
    Requires=network.target
    After=network.target
    
    [Service]
    #User=
    #Group=
    Type=forking
    WorkingDirectory=/
    PIDFile=/tmp/demon.pid
    ExecStart=/tmp/daemonProject
    ExecReload=/bin/kill -1 $MAINPID
    ExecStop=/bin/kill -- $MAINPID
    #KillSignal=SIQQUIT
    RestartSec=5
    Restart=always
    KillMode=mixed
    
    [Install]
    WantedBy=multi-user.target

    and works as expected, without this issues

    #include <dirent.h>
    #include <iterator>
    #include <cstdlib>
    #include <cstring>
    #include <sstream>
    #include <iostream>
    #include <stdlib.h>
    #include <string>
    #include <sys/stat.h>
    #include <syslog.h>
    #include <unistd.h>
    #include <vector>
    #include <fcntl.h>
    
    static char *pid_file_name = strdup("/tmp/demon.pid");
    static int pid_fd = -1;
    
    void do_heartbeat(const int x)
    {
       // TODO: implement processing code to be performed on each heartbeat
       syslog(LOG_INFO, "Hearbeat %d", x);
    }
    
    // For security purposes, we don't allow any arguments to be passed into the daemon
    int main(void)
    {
       // Define variables
       pid_t pid, sid;
    
       // Fork the current process
       pid = fork();
       // The parent process continues with a process ID greater than 0
       if(pid > 0)
       {
          exit(EXIT_SUCCESS);
       }
       // A process ID lower than 0 indicates a failure in either process
       else if(pid < 0)
       {
          exit(EXIT_FAILURE);
       }
       // The parent process has now terminated, and the forked child process will continue
       // (the pid of the child process was 0)
        /* Try to write PID of daemon to lockfile */
        if (pid_file_name != NULL) {
            char str[256];
            pid_fd = open(pid_file_name, O_RDWR | O_CREAT, 0640);
            if (pid_fd < 0) {
                /* Can't open lockfile */
                syslog(LOG_ERR, "Can't open pid file: %s", pid_file_name);
                exit(EXIT_FAILURE);
            }
            if (lockf(pid_fd, F_TLOCK, 0) < 0) {
                /* Can't lock file */
                syslog(LOG_ERR, "Can't lock pid file: %s", pid_file_name);
                exit(EXIT_FAILURE);
            }
            /* Get current PID */
            sprintf(str, "%d\n", getpid());
            /* Write PID to lockfile */
            write(pid_fd, str, strlen(str));
        }
       // Since the child process is a daemon, the umask needs to be set so files and logs can be written
       umask(0);
    
       // Open system logs for the child process
       openlog("demon", LOG_NOWAIT | LOG_PID, LOG_USER);
       syslog(LOG_NOTICE, "Successfully started daemon-name");
    
       // Generate a session ID for the child process
       sid = setsid();
       // Ensure a valid SID for the child process
       if(sid < 0)
       {
          // Log failure and exit
          syslog(LOG_ERR, "Could not generate session ID for child process");
    
          // If a new session ID could not be generated, we must terminate the child process
          // or it will be orphaned
          exit(EXIT_FAILURE);
       }
    
       // Change the current working directory to a directory guaranteed to exist
       if((chdir("/")) < 0)
       {
          // Log failure and exit
          syslog(LOG_ERR, "Could not change working directory to /");
    
          // If our guaranteed directory does not exist, terminate the child process to ensure
          // the daemon has not been hijacked
          exit(EXIT_FAILURE);
       }
    
    
       // A daemon cannot use the terminal, so close standard file descriptors for security reasons
       close(STDIN_FILENO);
       close(STDOUT_FILENO);
       close(STDERR_FILENO);
    
       // Daemon-specific intialization should go here
       const int SLEEP_INTERVAL = 5;
    
       // Enter daemon loop
       int x = 0;
       while(1)
       {
          // Execute daemon heartbeat, where your recurring activity occurs
          do_heartbeat(x);
          x++;
    
          // Sleep for a period of time
          sleep(SLEEP_INTERVAL);
       }
    
       // Close system logs for the child process
       syslog(LOG_NOTICE, "Stopping daemon-name");
       closelog();
    
       // Terminate the child process when the daemon completes
       exit(EXIT_SUCCESS);
    }
    nicraMarcin
    @nicraMarcin

    @oatpp_io_twitter I've made simple test. Just added LOGI after run() function

     try {
            run(oatpp::base::CommandLineArguments(argc, argv));
            OATPP_LOGI("main run()", "Before destroy")
            oatpp::base::Environment::destroy();
            OATPP_LOGI("main run()", "After destroy")
        } catch (std::runtime_error e) {
            OATPP_LOGE("main run()", "Runtime error: %s", e.what())
        } catch (...) {
            OATPP_LOGE("main run()", "GENERAL ERROR")
        }

    and non of this LOGI isn't printed, even Before destroy :(

    Oct 23 22:29:56 marcin-huawei /usr/bin/nmsapi[63118]: Starting nmsapi
    Oct 23 22:29:56 marcin-huawei /usr/bin/nmsapi[63118]: INFO (NmsComponent): Loading configuration from /etc/nms/nms.config.json
    Oct 23 22:29:56 marcin-huawei /usr/bin/nmsapi[63118]: INFO (CreateServerConnectionProvider): Server is configured with SSL and accepts only https://
    Oct 23 22:29:56 marcin-huawei /usr/bin/nmsapi[63118]: INFO (NMS): Server running on port 8443
    Oct 23 22:29:56 marcin-huawei /usr/bin/nmsapi[63118]: INFO (main): Running daemonized server
    Oct 23 22:29:56 marcin-huawei /usr/bin/nmsapi[63118]: INFO (main): Server NMS is running
    Oct 23 22:30:00 marcin-huawei /usr/bin/nmsapi[63118]: Debug: Reload config file
    Oct 23 22:30:02 marcin-huawei /usr/bin/nmsapi[63118]: Debug: received SIGTERM signal
    Oct 23 22:30:02 marcin-huawei /usr/bin/nmsapi[63118]: INFO (main): Daemon server is stopped
    Oct 23 22:30:03 marcin-huawei systemd[1]: nmsapi.service: Main process exited, code=dumped, status=6/ABRT
    Oct 23 22:30:03 marcin-huawei systemd[1]: nmsapi.service: Failed with result 'core-dump'.
    nicraMarcin
    @nicraMarcin

    couldn't be caused because of server run() is threaded:

     std::thread threadServer([&]() {
                server.run();
                {
                    std::lock_guard<std::mutex> lock(serverMutex);
                    running = false;
    
                }
                //server.stop();
                cv.notify_one();
            });
    
            std::unique_lock<std::mutex> lock(serverMutex);
            while (running) {
                syslog(LOG_INFO, "INFO (main): Server NMS is running");
                cv.wait(lock);
            }
            syslog(LOG_INFO, "INFO (main): Daemon server is stopped");

    This syslog is last what is logged

    nicraMarcin
    @nicraMarcin

    Ok, I think I've found cause of problem with exitting
    systemd with KillMode=mixed sends TERM to main process and KILL to others related I changed this to none and there is no problem with stoping

     try {
            run(oatpp::base::CommandLineArguments(argc, argv));
    
        } catch (std::runtime_error e) {
            OATPP_LOGE("main run()", "Runtime error: %s", e.what())
        } catch (...) {
            OATPP_LOGE("main run()", "GENERAL ERROR")
        }
    
        OATPP_LOGI("main run()", "Before destroy")
        oatpp::base::Environment::destroy();
        OATPP_LOGI("main run()", "After destroy")

    And Logs Before destroy but not after destroy.
    This solves problmem with stoping server. But problem with generating pid still exists but occours not everytime I start daemon

    Oct 23 22:49:31 marcin-huawei systemd[1]: nmsapi.service: Supervising process 65177 which is not our child. We'll most likely not notice when it exits.
    Oct 23 22:49:31 marcin-huawei /usr/bin/nmsapi[65177]: Starting nmsapi
    Oct 23 22:49:31 marcin-huawei /usr/bin/nmsapi[65177]: INFO (NmsComponent): Loading configuration from /etc/nms/nms.config.json
    Oct 23 22:49:31 marcin-huawei /usr/bin/nmsapi[65177]: INFO (CreateServerConnectionProvider): Server is configured with SSL and accepts only https://
    Oct 23 22:49:31 marcin-huawei /usr/bin/nmsapi[65177]: INFO (NMS): Server running on port 8443
    Oct 23 22:49:31 marcin-huawei /usr/bin/nmsapi[65177]: INFO (main): Running daemonized server
    Oct 23 22:49:31 marcin-huawei /usr/bin/nmsapi[65177]: INFO (main): Server NMS is running
    Oct 23 22:49:34 marcin-huawei /usr/bin/nmsapi[65177]: Debug: received SIGTERM signal
    Oct 23 22:49:34 marcin-huawei /usr/bin/nmsapi[65177]: INFO (main): Daemon server is stopped
    Oct 23 22:49:34 marcin-huawei systemd[1]: nmsapi.service: Succeeded.
    Oct 23 22:49:34 marcin-huawei /usr/bin/nmsapi[65177]: Objects count: 0, ObjectsCreated: 0
    Oct 23 22:49:34 marcin-huawei /usr/bin/nmsapi[65177]: INFO (main run()): Before destroy
    nicraMarcin
    @nicraMarcin
    Ok, I can't use OATP_LOGx() after I'm destroing environment :)
    oat++
    @oatpp_io_twitter
    Hey @nicraMarcin , yes, you can't use OATPP_LOGX after env is destroyed
    Did you manage to make everything work?
    nicraMarcin
    @nicraMarcin
    Non not everything. This Supervising process... still occours ☹️ but not in every start
    Kaung Zaw Htet
    @KaungZawHtet
    guys, what IDE/editor do u use?
    nicraMarcin
    @nicraMarcin
    CLion :)
    Kaung Zaw Htet
    @KaungZawHtet
    I used clion too in the past, now switch to vs code since It reached to stable version.
    bataak
    @bataak
    vim
    nicraMarcin
    @nicraMarcin
    Hello, I have problem with LibreSSL and OpenSSL in the same project.
    LibreSSL I've added installing into custom directory in my project. I use jwt-cpp as submodule which uses OpenSSL. Today I upgraded my jwt and have problems with compile. I thought that is jwt issuse but no. I created seperate test project and jwt works, so problem is with LibreSSL and OpenSSL in one project. Earlier jwt didn't have new methods and this why worked before.
    this is my CMakeLists.txt
     [...]
    set(OATPP_MODULES_LOCATION CUSTOM)
    set(OATPP_DIR_SRC "${CMAKE_SOURCE_DIR}/oatpp")
    set(OATPP_BUILD_TESTS OFF)
    set(OATPP_DISABLE_ENV_OBJECT_COUNTERS OFF) #OFF is enabled
    [...]
    include_directories(src include lib/argon2/include lib/hash-library)
    add_subdirectory(lib/oatpp)
    set(LIBRESSL_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/libressl-install")
    
    add_subdirectory(lib/oatpp-libressl)
    add_subdirectory(lib/oatpp-postgresql)
    add_subdirectory(lib/jwt)
    add_subdirectory(lib/mailio)
    [...]
    target_link_libraries(${project_name_lib}
            PUBLIC oatpp oatpp-libressl oatpp-postgresql pq jwt-cpp  crypto pthread ${ARGON2_LIBRARY} mailio
    )
    /home/marcin/Programs/CLion/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_BUILD_TYPE=Debug -DOATPP_MODULES_LOCATION=CUSTOM -DOATPP_DIR_SRC=/home/marcin/projects/nms/back/lib/oatpp -DOATPP_BUILD_TESTS=OFF -G "CodeBlocks - Unix Makefiles" /home/marcin/projects/nms/back
    CMake Warning (dev) at lib/oatpp/CMakeLists.txt:22 (option):
      Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
      --help-policy CMP0077" for policy details.  Use the cmake_policy command to
      set the policy and suppress this warning.
    
      For compatibility with older versions of CMake, option is clearing the
      normal variable 'OATPP_BUILD_TESTS'.
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    
    ############################################################################
    ## oatpp module compilation config:
    
    OATPP_DISABLE_ENV_OBJECT_COUNTERS=OFF
    OATPP_DISABLE_POOL_ALLOCATIONS=OFF
    OATPP_THREAD_HARDWARE_CONCURRENCY=AUTO
    OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT=10
    OATPP_COMPAT_BUILD_NO_THREAD_LOCAL=OFF
    
    ############################################################################
    
    oatpp version: '1.2.0'
    OATPP_ADD_LINK_LIBS=atomic
    
    ############################################################################
    ## oatpp-module-install.cmake
    
    OATPP_THIS_MODULE_NAME=oatpp
    OATPP_THIS_MODULE_VERSION=1.2.0
    OATPP_THIS_MODULE_LIBRARIES=oatpp;oatpp-test
    OATPP_THIS_MODULE_TARGETS=oatpp;oatpp-test
    OATPP_THIS_MODULE_DIRECTORIES=oatpp;oatpp-test
    
    ############################################################################
    
    CMake Warning (dev) at lib/oatpp-libressl/CMakeLists.txt:21 (option):
      Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
      --help-policy CMP0077" for policy details.  Use the cmake_policy command to
      set the policy and suppress this warning.
    
      For compatibility with older versions of CMake, option is clearing the
      normal variable 'OATPP_DIR_SRC'.
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    Finding oatpp in location=CUSTOM
    OATPP_DIR_SRC --> '/home/marcin/projects/nms/back/lib/oatpp'
    OATPP_DIR_LIB --> 'OFF'
    
    ############################################################################
    ## oatpp-libressl module. Resolving dependencies...
    
    LIBRESSL_INCLUDE_DIR=/home/marcin/projects/nms/back/lib/libressl-install/include
    LIBRESSL_TLS_LIBRARY=/home/marcin/projects/nms/back/lib/libressl-install/lib/libtls.a
    LIBRESSL_SSL_LIBRARY=/home/marcin/projects/nms/back/lib/libressl-install/lib/libssl.a
    LIBRESSL_CRYPTO_LIBRARY=/home/marcin/projects/nms/back/lib/libressl-install/lib/libcrypto.a
    LIBRESSL_LIBRARIES=/home/marcin/projects/nms/back/lib/libressl-install/lib/libcrypto.a;/home/marcin/projects/nms/back/lib/libressl-install/lib/libssl.a;/home/marcin/projects/nms/back/lib/libressl-install/lib/libtls.a
    LIBRESSL_VERSION=3.2.1
    
    ############################################################################
    
    target_link_oatpp(oatpp-libressl) to found in provided path oatpp lib
    
    ############################################################################
    ## oatpp-module-install.cmake
    
    OATPP_THIS_MODULE_NAME=oatpp-libressl
    OATPP_THIS_MODULE_VERSION=1.2.0
    OATPP_THIS_MODULE_LIBRARIES=oatpp-libressl
    OATPP_THIS_MODULE_TARGETS=oatpp-libressl
    OATPP_THIS_MODULE_DIRECTORIES=oatpp-libressl
    
    ############################################################################
    
    Finding oatpp in location=CUSTOM
    OATPP_DIR_SRC --> '/home/marcin/projects/nms/back/oatpp'
    OATPP_DIR_LIB --> 'OFF'
    
    ############################################################################
    ## oatpp-postgresql module. Resolving dependencies...
    
    PostgreSQL_INCLUDE_DIRS=/usr/include/postgresql;/usr/include/postgresql/12/server
    PostgreSQL_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpq.so
    PostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/12/server
    PostgreSQL_VERSION_STRING=12.4
    
    ############################################################################
    
    target_link_oatpp(oatpp-postgresql) to found in provided path oatpp lib
    
    ############################################################################
    ## oatpp-mod
    ############################################################################
    
    target_link_oatpp(oatpp-postgresql) to found in provided path oatpp lib
    
    ############################################################################
    ## oatpp-module-install.cmake
    
    OATPP_THIS_MODULE_NAME=oatpp-postgresql
    OATPP_THIS_MODULE_VERSION=1.2.0
    OATPP_THIS_MODULE_LIBRARIES=oatpp-postgresql
    OATPP_THIS_MODULE_TARGETS=oatpp-postgresql
    OATPP_THIS_MODULE_DIRECTORIES=oatpp-postgresql
    
    ############################################################################
    
    -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "1.1.1g", minimum required is "1.0.2")  
    -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1g")  
    /home/marcin/projects/nms/back/lib/argon2/libargon2.a
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/marcin/projects/nms/back/cmake-build-debug
    
    [Finished]

    but I have errors with jwt :(

     90%] Building CXX object CMakeFiles/nms.dir/src/controller/UserController.cpp.o
    In file included from /home/marcin/projects/nms/back/src/dto/Token.hpp:5,
                     from /home/marcin/projects/nms/back/src/service/tokenService.hpp:7,
                     from /home/marcin/projects/nms/back/src/service/tokenService.cpp:5:
    /home/marcin/projects/nms/back/lib/jwt/include/jwt-cpp/jwt.h: In member function ‘std::string jwt::algorithm::eddsa::sign(const string&, std::error_code&) const’:
    /home/marcin/projects/nms/back/lib/jwt/include/jwt-cpp/jwt.h:970:9: error: ‘EVP_DigestSign’ was not declared in this scope; did you mean ‘EVP_DigestSignInit’?
      970 |     if (EVP_DigestSign(ctx.get(),
          |         ^~~~~~~~~~~~~~
          |         EVP_DigestSignInit
    /home/marcin/projects/nms/back/lib/jwt/include/jwt-cpp/jwt.h: In member function ‘void jwt::algorithm::eddsa::verify(const string&, const string&, std::error_code&) const’:
    /home/marcin/projects/nms/back/lib/jwt/include/jwt-cpp/jwt.h:998:16: error: ‘EVP_DigestVerify’ was not declared in this scope; did you mean ‘EVP_DigestVerifyInit’?
      998 |     auto res = EVP_DigestVerify(ctx.get(),
          |                ^~~~~~~~~~~~~~~~
          |                EVP_DigestVerifyInit

    I think this is because my CLion reads openssl from libre folder :( instead of /usr/include/openssl/

    Zrzut ekranu z 2020-10-25 16-11-14.png
    nicraMarcin
    @nicraMarcin
    How to set main CMakeLists.txt to use OpenSSL for jwt?
    nicraMarcin
    @nicraMarcin
    @oatpp_io_twitter if oatpp would support openssl it would be excelent, please
    oat++
    @oatpp_io_twitter

    Hey @nicraMarcin ,

    How to set main CMakeLists.txt to use OpenSSL for jwt?

    I guess you have to modify jwt/CMakeLists.txt to target_(include/link) correct libraries.

    @oatpp_io_twitter if oatpp would support openssl it would be excelent, please

    I plan to work on this in the nearest future

    nicraMarcin
    @nicraMarcin
    @oatpp_io_twitter I added include_directories(/usr/include) but CLion still was showed
    Kaung Zaw Htet
    @KaungZawHtet
    @oatpp_io_twitter btw, I wish u could join nxt-year cppcon for sharing oatpp stuff.
    I found some lib authors share thier lib stuff at cppcon too.
    Bhupesh25
    @Bhupesh25
    @oatpp_io_twitter, how can I calculate total number of documents in our oatpp-mongo module?
    I meant count
    oat++
    @oatpp_io_twitter

    @oatpp_io_twitter btw, I wish u could join nxt-year cppcon for sharing oatpp stuff.

    Hey @KaungZawHtet , It may be a good idea. Will see how it goes next year with all the pandemic stuff.

    @Bhupesh25 ,

    Please read mongo docs.
    Also, I've googled this answer for you - https://stackoverflow.com/questions/63953997/mongocxx-count-documents-in-collection

    oat++
    @oatpp_io_twitter

    Hey @/all ,
    :bell:

    The 1.2.0 is finally released and has received its git tag :tada: :tada: :tada:
    This was a hard one, but also a fun one. And we keep going!

    Please find the updated changelog - any questions are welcome!

    Cheers,
    Leonid

    nicraMarcin
    @nicraMarcin
    👍
    nicraMarcin
    @nicraMarcin

    @oatpp_io_twitter

    message=[oatpp::parser::json::mapping::Deserializer::deserializeEnum()]: Error. Can't deserialize Enum.

    Is it posiible, to get which field can't be deserialized?

    oat++
    @oatpp_io_twitter

    @nicraMarcin ,

    Please file an issue for this one.

    Also, if you want to contribute:

    https://github.com/oatpp/oatpp/blob/master/src/oatpp/parser/json/mapping/Deserializer.cpp#L262

    • It's possible to output the type - easy.
    • output name a bit harder, but also possible.
    nicraMarcin
    @nicraMarcin
    ok
    ngalanmanlok
    @ngalanmanlok
    Hi, I'd like to know if I can create an endpoint for uploading files (using multipart or anything that works) and let users upload their files through swagger UI? If yes, could you please provide me with an example?
    oat++
    @oatpp_io_twitter
    Hey @ngalanmanlok , yes, its possible.
    I'll be online in an hour. Will post a snippet here
    ngalanmanlok
    @ngalanmanlok
    @oatpp_io_twitter thank you so much for the prompt reply :)
    Stéphane Laurin
    @slaurin
    Hi, I am wondering if oat++ multipart upload supports progress status?
    oat++
    @oatpp_io_twitter
    Hey guys, 10 mins, and I'll be online :)
    oat++
    @oatpp_io_twitter

    Hey @ngalanmanlok ,

      ENDPOINT_INFO(upload) {
        info->addConsumes<oatpp::swagger::Binary>("application/octet-stream"); // tell swagger that it's a file
      }
      ENDPOINT("POST", "upload", upload,
               BODY_STRING(oatpp::String, file))
      {
        OATPP_LOGD("AAA", "file: size=%d, content='%s'", file->getSize(), file->c_str());
        // Save file here
        return createResponse(Status::CODE_200, "File uploaded");
      }

    Please note that oatpp does not support Expect: 100-continue header. So make sure that client does not include this header when uploading the file.

    I've just tried to upload photos up to 6Mb through swagger UI and it worked. Not sure when or if swagger will include Expect: 100-continue header with larger files.

    oat++
    @oatpp_io_twitter
    Hey @slaurin
    All you have to do is to extend multipart reader:
    namespace multipart = oatpp::web::mime::multipart;
    
    class MyReader : public multipart::Reader {
    public:
    
      MyReader(multipart::Multipart* multipart) : multipart::Reader(multipart) {}
    
      oatpp::v_io_size write(const void *data, v_buff_size count, oatpp::async::Action& action) override {
        OATPP_LOGD("Progress", "+=%d", count); 
        return multipart::Reader::write(data, count, action);
      }
    
    };

    Then your endpoint will be as follows:

    
    ENDPOINT("POST", "multipart", multipart,
             REQUEST(std::shared_ptr<IncomingRequest>, request))
    {
    
      /* Prepare multipart container. */
      auto multipart = std::make_shared<multipart::PartList>(request->getHeaders());
    
      MyReader multipartReader(multipart.get());
    
      multipartReader.setDefaultPartReader(multipart::createInMemoryPartReader(1024 /* max-data-size */));
    
      request->transferBody(&multipartReader);
    
      for(auto& part : multipart->getAllParts())  {
        OATPP_LOGD("part", "name=%s, known_size=%d", part->getName()->c_str(), part->getKnownSize());
      }
    
      return createResponse(Status::CODE_200, "OK");
    
    }

    And here is the curl to test

    curl http://localhost:8000/multipart -F key1=value1 -F key2=value2 -H "Expect: "

    @slaurin ,

    And the total amount to upload you can get from Content-Length header if it's present

    Stéphane Laurin
    @slaurin
    @oatpp_io_twitter thank you for the quick response it appreciated.
    oat++
    @oatpp_io_twitter
    👍