## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
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?
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

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 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 An Tao @an-tao 1 reply 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 have added the following to the path environment variables: vcpkg\installed\x64-windows\bin, lib and include