Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    An Tao
    @an-tao

    Hi, is anyone know how to change cookie domain name?

    I don't think drogon sends domain name in session cookie, please confirm it via packet capturing tools.

    1 reply

    hi @an-tao, we have an issue related to LOG_DEBUG macro. When we integrate our system with an external logging system which uses syslog, as syslog has same macro it is overriding. Is it possbile to use some prefix before those macros. LOG_DEBUG, LOG_ERROR etc is very common and mostly logging libraries uses them.

    The solution I can think of is to compile your app with dragon source code, then resolve the conflict by string replacing

    Ichiro
    @HadesD

    how can I make two request not blocking each-others?
    Currently my problem:

    • request1: run with block HttpClient Request inside
    • request2: has to wait request1 completed (callback)

    How can I continue request2 without wait request1 to completed?

    Ichiro
    @HadesD
    ok, I use coro + CurrentThreadEventLoop then it solved problem
    I think you should add document to coroutines https://drogon.docsforge.com/master/coroutines/#enabling-coroutines
    add example of HttpClient also
    @an-tao
    Ichiro
    @HadesD
    Re-tested
    I 've found this, if I build drogon with ./build.sh -t , it not problem with deadlock when use coro.httpclient on controller, without -t flag, it will be trouble with deadlock
    house-mouse
    @house-mouse
    Hello Drogon folks! Thanks for your awesome work on this project! I am wondering if it's possible to have wildcards in websocket urls? Can something like WS_PATH_ADD("/session/{1}") be used and then the path parameter picked up in some way similar to how METHOD_ADD works with something like METHOD_ADD(Book::getInfo,"/{1}",Get); ? It looks like METHOD_ADD doesn't have any method like Ws akin to Get or Post to be able to catch things before websocket negotiation fully turns the request into a websocket connection, so I'm not sure where or how I might be able to grab the url early in the negotiation? Thanks for any thoughts!
    An Tao
    @an-tao
    Currently you can't do that. WebsocketController is just like HttpSimpleController. it doesn't support parameters mapping. you can add your parameters to the query string or the body of requests.
    house-mouse
    @house-mouse
    Thanks for the quick reply!
    P.R.
    @prothegee

    Hi everyone,
    what is the equivalent of:

    auto cmd = R"(
        update public.account_verification_email set token_expired=true where email=$1;
    )";
    db->execSqlAsyncFuture(cmd, u_email);

    in drogon::orm ?

    <br>

    I tried:

    orm::Mapper<AccountVerificationEmail> aveMP(db);
    
    aveMP.updateFutureBy(
        AccountVerificationEmail::Cols::_token_expired,
            orm::Criteria(AccountVerificationEmail::Cols::_email,
            orm::CompareOperator::Like, u_email),
                true);

    but gets error:

    [build] /home/prg/backend/beCPP/db/postgresdb.h:326:53: note:   cannot convert ‘drogon_model::database_name::AccountVerificationEmail::Cols::_token_expired’ (type ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’}) to type ‘const std::vector<std::__cxx11::basic_string<char> >&’
    [build]   326 |                     AccountVerificationEmail::Cols::_token_expired,
    [build]       |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

    these column was actually boolean.

    Can someone correct me which part should be change?

    Raw sql command is fine, but I want to maximize using drogon orm.

    An Tao
    @an-tao
    The first parameter of the update method is a vector for updating multiple columns, try this:
    aveMP.updateFutureBy(
        {AccountVerificationEmail::Cols::_token_expired},
            orm::Criteria(AccountVerificationEmail::Cols::_email,
            orm::CompareOperator::Like, u_email),
                true);
    1 reply
    HadiAbbasi
    @HadiAbbasi
    Hi
    I wanna create a none-blocking parallel thread (maybe like future) as I wanna execute a scenario (function) with thread sleep (like change in a file after 30 seconds for my tests)!
    I didn't find any solution in drogon!
    even when I wanna use std::thread , there is an unknown error which stops drogon server!
    "terminate called without an active exception"
    could you please help me to find my solution?
    thanks a lot...
    All The Best,
    Hadi
    11 replies
    ammanabrolua
    @ammanabrolua
    hi
    is there a way to upload videos in drogon?
    please let me know of any examples
    Rafael Bugajewski
    @rbugajewski
    @ammanabrolua Did you already try with newFileUploadRequest? — https://drogon.docsforge.com/master/api/drogon/HttpRequest/newFileUploadRequest/
    And if you mean the other direction, then just take a look at the upload example — https://github.com/drogonframework/drogon/blob/master/examples/file_upload/file_upload.cc
    ammanabrolua
    @ammanabrolua
    How to navigate from one .csp to another. csp file?
    on click of button
    ?
    Please let me know
    Also, how to pass the data in this case?
    ammanabrolua
    @ammanabrolua
    How to create json array in drogon c++?
    1 reply
    ammanabrolua
    @ammanabrolua
    I have a question if video streaming possible in drogon?
    Ichiro
    @HadesD
    image.png
    @an-tao
    drogon doesnot support this?
    WojciechMigda
    @WojciechMigda
    Hi, if I were to use both drogon and boost.asio in a single program, is there a recommended way to do that, preferrably without launching separate threads for each?
    1 reply
    Suganthan BC
    @SuganthanBC

    I have a question if video streaming possible in drogon?

    I wonder the same

    An Tao
    @an-tao
    you could use the trantor::Logger::setOutputFunction() method to output drogon logs to your log system.
    Suganthan BC
    @SuganthanBC

    I am getting an error while trying to run drogon_ctl:

    drogon_ctl: error while loading shared libraries: libjsoncpp.so.25: cannot open shared object file: No such file or directory

    1 reply
    Does anybody have a clue on how to resolve this? I cloned jsoncpp on the $WORK_PATH
    and of course follwed all the instructions and did make && sudo make install
    mike
    @gnu-enjoyer
    when using a custom constructor HttpController w/ .registerController(ctrlPtr) before .run() the ctor runs OK but it doesn't seem to route the path e.g. /test as a GET method never calls the Controller's method. I've tried Cmake .. etc. to regenerate the proj am I missing something? I can get all the examples working so I'm thinking my issue is w/ the InitPathRouting stuff
    mike
    @gnu-enjoyer
    nvm think I fixed it by using ADD_METHOD_TO macro instead of METHOD_ADD
    TennisBowling
    @TennisBowling
    hey, how can I get a request's body?
    with registerHandler
    (like inside of that lambda)
    An Tao
    @an-tao
        app().registerHandler(
            "/hello",
            [](const HttpRequestPtr &req,
               std::function<void(const HttpResponsePtr &)> &&callback)
               {
                    LOG_DEBUG << req->body();
                    callback(drogon::HttpResponse::newHttpResponse());
              });
    ScaredLaptop
    @ScaredLaptop
    Is there a reason why the program would be segfaulting on the mapper.findAll when I try to access the endpoint generated by the restful controllers?
    An Tao
    @an-tao
    Sounds like a bug, would u please make a simple example to reproduce this issue, I'll figure it out.
    5 replies
    Behnam Sabaghi
    @FONQRI

    Hi.
    In documents written response->getJsonObject() will return an empty shared_ptr of response is not json object but for me it's cause crash

    20220725 08:28:44.788119 UTC 45246 ERROR * Line 1, Column 1
      Syntax error: value, object or array expected.
     - HttpResponseImpl.cc:832
    20220725 08:28:44.788201 UTC 45246 ERROR body: <html>
    <head><title>404 Not Found</title></head>
    <body bgcolor="white" text="black">
    <center><h1>404 Not Found</h1></center>
    <hr><center>drogon/1.7.5</center>
    </body>
    </html>
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
     - HttpResponseImpl.cc:833
    Press <RETURN> to close this window...

    Am I mistaken?

    2 replies
    Greisberger Christophe
    @Greisby

    Hi, I have a question regarding the AOP of drogon (https://drogon.docsforge.com/master/aop-aspect-oriented-programming/#aop-schematic)

    Is it possible to graft somewhere between the pre-handling join-point and the Hander to do some kind of task during the processing of the data of an http request? The default handler is called only at the end of the upload.

    For example: on a file upload, insert a callback that creates on start a database entry, so that the file is immediately available for clients, then updates the databse entry during the upload.

    Intended usage: record audio and send it chunked to the server until the end of the recording, AND make the partial audio file immediately available for re-serving for other clients (play during record).

    6 replies
    Arpan Sen
    @arpan-ventura
    Hello Drogon folks! Is there a way to rate limit/conflate the messages of the Drogon Websocket Server. I need the websocket server to publish no more than 1 message/sec per topic. I am planning to use Redis as the source of truth for the Websocket Server FYI
    Ichiro
    @HadesD
    I'm trying to use trantor::TcpClient as bellow code, and it always throw connect fail
            trantor::InetAddress inetInfo("127.0.0.1", 1102);
    
            auto socketClient =
                trantor::TcpClient(trantor::EventLoop::getEventLoopOfCurrentThread(), inetInfo, "kick-ass-gamer");
    
            try {
                socketClient.setConnectionCallback([](const trantor::TcpConnectionPtr &conn) {
                    if (conn->connected()) {
                        LOG_INFO << "connected to db";
                    } else {
                        LOG_ERROR << "connect to db failed";
                    }
                });
                socketClient.setConnectionErrorCallback([]() { LOG_DEBUG << "connect to db error"; });
                socketClient.connect();
    
                const auto connPtr = socketClient.connection();
                if (!connPtr) {
                    throw std::runtime_error("Connect to db failed #" + std::to_string(server.getValueOfId()));
                }
    
                // connPtr->send(reinterpret_cast<const char *>(&packets[0]), packets.size());
    
                socketClient.disconnect();
            } catch (const std::exception &e) {
                LOG_ERROR << e.what();
            }
    
            socketClient.stop();
    5 replies
    Marcos Oliveira
    @terroo
    Does anyone have a basic MySQL connection test example?
    Rafael Bugajewski
    @rbugajewski
    @terroo You can take a look at the examples in the official documentation - https://drogon.docsforge.com/master/database-general/
    ℜ𝔦𝔰𝔦𝔫𝔤 𝔊𝔲𝔞𝔯𝔡𝔦𝔞𝔫𝔬
    @scuroguardiano:matrix.scuroguardiano.net
    [m]
    Hello
    How can I use built in drogon logger to log my custom messages? I couldn't find it in the docs...
    ℜ𝔦𝔰𝔦𝔫𝔤 𝔊𝔲𝔞𝔯𝔡𝔦𝔞𝔫𝔬
    @scuroguardiano:matrix.scuroguardiano.net
    [m]
    oh nvm, I just found above <3
    It's beautiful