Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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
    Rafael Bugajewski
    @rbugajewski
    thank you very much :)
    Laureu
    @Laureu

    Hello, all !

    I'm trying to send a request to a Keycloak thanks to an HttpRequest, created with newHttpFormPostRequest() (as Keycloak only accept content type: application/x-www-form-urlencoded).
    I'm getting an error /home/user/drogon/lib/src/HttpRequestImpl.cc:313: void drogon::HttpRequestImpl::appendToBuffer(trantor::MsgBuffer*) const: Assertion !(!content.empty() && !content_.empty()) failed.
    What should I do ?
    Also, for this type of request, should I fill my form entries thanks to the setParameter() method or thanks to the setBody() ? It seems that x-www-form-urlencoded requests puts everything in the Body.

    Thanks a lot for your answers !

    An Tao
    @an-tao
    you should use the setParameter() method to add your form entries.
    Laureu
    @Laureu
    Thanks for your answers, what about the assert, do you have an idea ?
    An Tao
    @an-tao
    Would you like to make a demo repo on github to reproduce this issue? I'll figure it out with that.
    vignesh
    @vicky1990
    Hi everyone! I am working on a project where I need to insert array of images to postgres db. So, I made the column array of bytea but the generated api from Drogon ORM model seems to expect input as string. Does it mean Drogon ORM doesnt support bytea/array? Any help or link is appreciated. Thanks
    Sudheendra
    @sudheendra
    Hey Everyone, i am trying to use drogon httpclient to download a data of size 4GB, the RAM that i have in my machine is 5GB. I get a crash all the time, when i try to download this large file. Is there a way to download this chunk by chunk.
    On the server side FileResponse is used to read the filedata and send it back to client.
    22 replies
    Bahman Yunuszoda
    @Baxulio
    Hello everybody! How to get host IP addresses through drogon framework?
    An Tao
    @an-tao

    Hello everybody! How to get host IP addresses through drogon framework?

    you could use the req->localAddr() method to get it.

    1 reply
    ℜ𝔦𝔰𝔦𝔫𝔤 𝔊𝔲𝔞𝔯𝔡𝔦𝔞𝔫𝔬
    @scuroguardiano:matrix.scuroguardiano.net
    [m]
    Are drogon Plugins something like services in for example ASP.NET?
    An Tao
    @an-tao
    not quite the same, plugins can be thought of as special configurable components that can be loaded at runtime
    Please refer to drogon's built-in plugins in lib/inc/drogon/plugins
    ℜ𝔦𝔰𝔦𝔫𝔤 𝔊𝔲𝔞𝔯𝔡𝔦𝔞𝔫𝔬
    @scuroguardiano:matrix.scuroguardiano.net
    [m]
    Oh I see, thanks
    But it's ok to use them as some sort of services, right? For example if I had some kind of movies database, I would create plugin something like MoviesPlugin and I would use this plugin as a service that would interact with ORM.
    So it would be model Movie, MoviesPlugin and MoviesController
    Is this correct approach in drogon or should I do it differently?
    An Tao
    @an-tao
    Yes, you can do that, It depends on your programming preferences and habits
    10 replies
    vignesh
    @vicky1990
    Hi all.. The link no longer exist.. https://github.com/drogonframework/drogon/tree/master/examples/simple_example_test .. Any other link that shows example for how to test user defined controller and rest api? Thanks
    Jakub Vlk
    @vlccek

    Hi, i have a problem with dbClient creation. When i try to use different host than 127.0. 0.1 on run time says "Socket fd < 0, Usually this is because the number of files opened by the program exceeds the system limit. Please use the ulimit command to check. - PgConnection.cc:71"

      "db_clients": [
        {
          //name:Name of the client,'default' by default
          //"name":"",
          //rdbms:server type, "postgreSQL" by default
          "rdbms": "postgresql",
          //host:server address,localhost by default
          "host": "drogondb.do",
          //port:server port, 5432 by default
          "port": 5432,
          //dbname:Database name
          "dbname": "hello_world",
          //user:'postgres' by default
          "user": "benchmarkdbuser",
          //passwd:'' by default
          "passwd": "benchmarkdbpass",
          //is_fast: false by default, if it is true, the client is faster but user can't call
          //any synchronous interface of it.
          "is_fast": true,
          //connection_number:1 by default
          "connection_number": 1,
          "auto_batch": false
        }

    i'am using this config, what i'm missing?

    An Tao
    @an-tao
    I'm not sure if domain names are supported, try using an IP address.
    Jakub Vlk
    @vlccek
    I am using podman for containerize db and drogon. I'm not sure if i can use ip address
    Jakub Vlk
    @vlccek
    and it doesn't work even with IP addres. Same problem
    An Tao
    @an-tao
    I tested on my local machine, domain names are supported with postgresql.
    4 replies
    Sudheendra
    @sudheendra
    Hi. I am looking for Drogon HTTPClient API which write the data received from server into a file directly, without storing any data in memory (probably chunk by chunk). Let me know if there is some API that i could use for this.
    An Tao
    @an-tao
    Now there is no API for that. A possible solution is using mmap function to store data to a temparary file when receiving a large response from the server.
    There are some works to do in Drogon for that.
    Behnam Sabaghi
    @FONQRI
    hi. i have a websocket server with drogon and when my client reset his system I don't get disconnect callback for some minutes. my ping message from server is set for 5 second and i set IdleConnectionTimeout to 5 @an-tao
    11 replies
    vignesh
    @vicky1990
    Hi all.. Any C++ open-source library suggestion to create pdf in drogon backend? Asking here just to check if anyone has already found a good one to use with drogon.. Thanks
    clapfootrohun
    @clapfootrohun

    Hello, I've followed the windows installation instructions. I setup a project using dragon_ctl. I'm using VS2019 with C++ 20

    I'm getting a linker error when calling into certain functions like drogon::getVersion() or HttpResponse::getBody()

    Error    LNK2019    unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl drogon::getVersion(void)" (?getVersion@drogon@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function main

    I've also tried using C++14 and boost and got the same linker error.
    I have added the following to the path environment variables: vcpkg\installed\x64-windows\bin, lib and include

    I noticed a similar issue is open currently: drogonframework/drogon#1202

    Does anyone have any ideas about how to fix this?

    roger-tannous
    @roger-tannous

    Hello, I need to introduce some classes in my project as utility classes to be invoked later in my controllers in Drogon.

    I guess I can implement them as plugins (although there's a base class (DivisionsQueryBuilder at a specific namespace) which only has pure virtual functions), even if their initAndStart() function won't actually do anything yet.

    What is the best practice in this case ?

    In fact, I need to instantiate a class that builds me a query according to the parameters it's being given (dynamic query building).
    For a specific type (hotel), it instantiates HotelDivisionsQueryBuilder (which extends DivisionsQueryBuilder and implements pure virtual function virtual std::string_view buildQuery(...))

    Is there any suggested best practice on where to put the files (certainly not in the controllers, views, or the filters folders) and if it's clean and legit to create them as plugins ?
    Note that this supposedly created "plugin" will be doing nothing, until buildQuery is invoked.

    If the suggested solution is to use HotelDivisionsQueryBuilder as plugin, is it also mandatory that its parent class DivisionsQueryBuilder also be a plugin ?

    Garminston
    @Garminston
    Is mysql supported? I get following error: FATAL Mysql is not supported!
    roger-tannous
    @roger-tannous
    @Garminston Did you fill the related section in config.json ? There's a section for DB clients.
    @Garminston, if you did, then you've missed an important step in the initial setup. Note that you have to install the client library for your database prior to building (prior to cmake, make) Drogon. For mysql, the docs say you should install libmariadbclient instead of libmysqlclient because the MySQL client library doesn't support asynchronous calls. So first install libmariadbclient then cmake and make Drogon (check the docs) then whenever you have the proper configuration in config.json, you must be able to use the DBClient.
    roger-tannous
    @roger-tannous
    @an-tao, is configuration db_clients - host has to be strictly an IP address for a remote DB server ? Can it take an fqdn ?
    Garminston
    @Garminston
    I got it to work. I have installed drogon using vcpkg as follows: vcpkg install drogon[ctl,mysql]:x64-windows
    roger-tannous
    @roger-tannous
    @Garminston, I thought you're one some Linux flavor :)
    roger-tannous
    @roger-tannous
    On some Linux flavor * (blame it on the mobile phone's keyboard)
    An Tao
    @an-tao

    @an-tao, is configuration db_clients - host has to be strictly an IP address for a remote DB server ? Can it take an fqdn ?

    you can use hostname or domain name as well.

    Hello, I need to introduce some classes in my project as utility classes to be invoked later in my controllers in Drogon.

    I guess I can implement them as plugins (although there's a base class (DivisionsQueryBuilder at a specific namespace) which only has pure virtual functions), even if their initAndStart() function won't actually do anything yet.

    What is the best practice in this case ?

    In fact, I need to instantiate a class that builds me a query according to the parameters it's being given (dynamic query building).
    For a specific type (hotel), it instantiates HotelDivisionsQueryBuilder (which extends DivisionsQueryBuilder and implements pure virtual function virtual std::string_view buildQuery(...))

    Is there any suggested best practice on where to put the files (certainly not in the controllers, views, or the filters folders) and if it's clean and legit to create them as plugins ?
    Note that this supposedly created "plugin" will be doing nothing, until buildQuery is invoked.

    If the suggested solution is to use HotelDivisionsQueryBuilder as plugin, is it also mandatory that its parent class DivisionsQueryBuilder also be a plugin ?

    You can think of drogon's plugin as a singleton implementation that can be configured and loaded at runtime.

    roger-tannous
    @roger-tannous
    @an-tao, thank you for the responses. I tried to reply to myself in the same thread but the option is not there, at least on the mobile version. I made a plugin that invokes other classes, and those classes are not being set as plugins. Currently, I have them in the same folder and included like #include "plugins/...", so it seems I can move them to a folder outside the plugins folder and modify the path accordingly in the #include directive.
    1 reply
    Ghost
    @ghost~630eac146da03739849c0a49
    Hi, is Drogon ready for production environment?
    2 replies
    Arun
    @carun
    Hello @an-tao and everyone, can we migrate to this chat to Zulip? Please see https://zulip.com/for/open-source/
    2 replies
    Mr Kelly
    @ArchNemsys_gitlab
    Setting up drogon to server static pages and a few websocket responses. upon running it threw errors about generating the tmp file storage in a non writable directory fair enough. My app doesn't need uploads so would like to disable file uploads is it possible ? had a quick skim through the documentation and source code (both are excellent by the way) best I could figure was to implement a filter and reject requests of ContentType multipart/form-data; but I would have to apply the filter to all paths ? for a default configures drogon app are uploads even handled ie if I haven't written code for it does the error merely mean that the tmps couldn't be created but drogon wasn't ever going to use them ?
    An Tao
    @an-tao
    Drogon doesn't implement any default upload behavior if you haven't written code for it ( using MultipartParser for uploading files). but the tmp folder is used by drogon sometimes, when the body of a request is very large, drogon saves the request in a temporary file instead of in memory, the temporaryfile is in the tmp folder. please refer to the client_max_memory_body_size option in the configuration file.
    if you want to implemant a global filter, you could use the AOP interface of drogon, register a preRouting advice to drogon
    Mr Kelly
    @ArchNemsys_gitlab
    Thankyou, trying to get locations work have setup a default project and using the provided config file, I have placed a file called test to ~/Projects/drogon_location/build/.well-known/acme-challenge/test. no log file is written but stdout reports
    20220907 06:52:16.985824 UTC 2377 TRACE [onAsyncRequest] http path=/.well-known/acme-challenge/test - HttpAppFrameworkImpl.cc:825
    20220907 06:52:16.985866 UTC 2377 TRACE [newTemplate] http view name=drogon::NotFound - DrTemplateBase.cc:26
    An Tao
    @an-tao
    please refer to the file_types option in config.json