Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 25 17:37
    lgtm-com[bot] opened #664
  • Nov 25 09:33
    cyang-catalogicsoftware commented #662
  • Nov 25 09:22
    cyang-catalogicsoftware commented #662
  • Nov 25 03:46
    YundongGai commented #626
  • Nov 25 01:41
    SSDGADsss commented #662
  • Nov 24 08:03
    Peibohao commented #663
  • Nov 24 07:46
    csyJoy opened #663
  • Nov 24 04:25
    cyang-catalogicsoftware opened #662
  • Nov 24 03:49
    cyang-catalogicsoftware closed #658
  • Nov 23 03:47
    kekxv commented #661
  • Nov 23 00:46
    kekxv opened #661
  • Nov 22 13:28
    asiirtol opened #74
  • Nov 18 07:21
    djassie commented #630
  • Nov 17 03:32
    doufu3344 commented #599
  • Nov 17 03:31
    doufu3344 opened #660
  • Nov 17 02:01
    doufu3344 commented #639
  • Nov 16 00:27
    lganzzzo commented #652
  • Nov 15 23:48
    lganzzzo labeled #653
  • Nov 15 23:48
    lganzzzo commented #653
  • Nov 15 23:24
    lganzzzo commented #658
EnderTheCoder
@EnderTheCoder
Also, another query with this table worked well. So I don't think it's a problem with the table.
EnderTheCoder
@EnderTheCoder
Never mind, it's a table problem. Sorry for my stupid mistake.
Jan Weßling
@frosk1

Hey,

does the c++ web framework oat++ needs to be serverd via an external webserver over CGI/ FastCGI or does oat++ comes with its own http web server?

oat++
@oatpp_io_twitter
Hello @frosk1 , Oat++ comes with its own http web server
Jan Weßling
@frosk1
thx @oatpp_io_twitter understood. Are there any benchmarks of this http web server vs some other languages like python (gunicorn server, uswgi server, etc.) or go( gin http server) ?
Fabrice Aeschbacher
@fabrice.aeschbacher_gitlab
I'm looking for a way to redirect http requests (port=80) to my oatpp https server listening on port 443. To be able to send a Status::CODE_302 response, the oatpp server should listen on ports 80 and 443. What is the recommended method for doing this ?
oat++
@oatpp_io_twitter

Hey @frosk1 ,

thx @oatpp_io_twitter understood. Are there any benchmarks of this http web server vs some other languages like python (gunicorn server, uswgi server, etc.) or go( gin http server) ?

For oatpp 1.1.0 - https://www.techempower.com/benchmarks/#section=data-r21&test=json
Also you may search on github - there must be some repos with benchmarks like this one https://github.com/memen45/server_benchmark

Hello @fabrice.aeschbacher_gitlab ,

I'm looking for a way to redirect http requests (port=80) to my oatpp https server listening on port 443. To be able to send a Status::CODE_302 response, the oatpp server should listen on ports 80 and 443. What is the recommended method for doing this ?

Yes, you have to listen on both ports.
And you have to add Interceptor on port 80 to redirect to 443 - like here https://github.com/oatpp/website/blob/master/server/main/src/SitePath.hpp#L46

How to setup component - you can find here - https://github.com/oatpp/website/blob/master/server/main/src/AppComponent.hpp

1 reply
bturksonmez
@bturksonmez
Hello all,
image.png
What are the prerequisites for MacOS?
I could not find it in the installation documentation.
Jan Weßling
@frosk1
Thx for the response
Ivansete
@Ivansete

Morning!
In order to reduce the number of warnings (possible loss of data). Is it a good idea to apply the next change in oatpp/core/base/Environment.hpp ?

-typedef intptr_t v_buff_size;
+typedef v_int64 v_buff_size;

cc90202
@cc90202
yanalex66
@yanalex66

Hi Everyone

A client can send a request that requires significant time (minutes) and resources, and then disconnect before the response is ready.

Is there a smart way to detect on I/O level that the connection that initiated the request is closed and pass this information to the request executor?

yanalex66
@yanalex66
I use async controller
oat++
@oatpp_io_twitter

Hello @Ivansete ,

In order to reduce the number of warnings (possible loss of data). Is it a good idea to apply the next change in oatpp/core/base/Environment.hpp ?
-typedef intptr_t v_buff_size;
+typedef v_int64 v_buff_size;

Yes it should be safe.
Are you on 32bit platform?

oat++
@oatpp_io_twitter

Hello @yanalex66 ,

A client can send a request that requires significant time (minutes) and resources, and then disconnect before the response is ready.
Is there a smart way to detect on I/O level that the connection that initiated the request is closed and pass this information to the request executor?

Yes, on I/O level it's possible. However, by that moment oatpp had already delegated processing to Endpoint, and oatpp will not terminate that processing until it's finished.

oat++
@oatpp_io_twitter
You may try using WebSocket instead of HTTP.
In this case you will receive an actual notification that the client dropped.
Since WebSocket is event-based protocol (unlike http) you can receive messages in the middle of your processing.
yanalex66
@yanalex66

Hello @oatpp_io_twitter

Thanks for your response.

I'll ponder on the idea of WebSocket. A good idea actually but my clients are HTTP ones (at least, for now).

Yes, on I/O level it's possible. However, by that moment oatpp had already delegated processing to Endpoint, and oatpp will not terminate that processing until it's finished.

I'll try then to find a way to signal the endpoint that response is not required and stop the request processing.

so to stop the request processing not by the framework but by the mechanism that calculates the response
oat++
@oatpp_io_twitter
:thumbsup:
IO-create
@IO-create
Can any one help me with how to upload and download files by using forms?
IO-create
@IO-create
In Simple API Multipart Upload how to get data of file that is uploaded and store in database
jm130794
@jm130794
Hello,
What is the role of the BUNDLE macro in a controller?
cc90202
@cc90202
Pardon me, but I'm very newbie on websocket. I'm studying the oatpp websocket server and client example. 1) for Server example: how can I connect to the example endpoint ws? If I see the client example I see v3/channel_1/KEY. 2) regarding the client example KEY: how is calculated this key? thanks for any answer.
Emreiris
@Emreiris
Hi, I want to build oatpp with GCC compiler on Windows operation system. I tried to generate a build with CMake via command (cmake .. -G "MinGW Makefiles") and then (make install) but it only created library for linux. Long story in short, how can I compile oatpp with gcc?
oat++
@oatpp_io_twitter

Hello @IO-create

Can any one help me with how to upload and download files by using forms?
In Simple API Multipart Upload how to get data of file that is uploaded and store in database

You can find example code here - https://github.com/oatpp/oatpp/blob/master/changelog/1.3.0.md#better-multipart

1 reply

Hello @jm130794

What is the role of the BUNDLE macro in a controller?

Bundle is used to read bundle data that was set ex.: in RequestInterceptor.
You can find example here:

oat++
@oatpp_io_twitter

Hello @cc90202

Pardon me, but I'm very newbie on websocket. I'm studying the oatpp websocket server and client example. 1) for Server example: how can I connect to the example endpoint ws? If I see the client example I see v3/channel_1/KEY. 2) regarding the client example KEY: how is calculated this key? thanks for any answer.

Client example is just a regular websocket client which connects to the 3rd-party service (https://www.piesocket.com/).
The key there is one provided by that 3rd party service.
If you connect to your own service - then you don't need that key.

oat++
@oatpp_io_twitter

Hello @Emreiris ,

mand (cmake .. -G "MinGW Makefiles") and then (make install) but it only created library for linux. Long story in short, how can I compile oatpp with gcc?

Try to compile oatpp on windows using Visual Studio - just follow easy steps as described here - https://oatpp.io/docs/installation/windows/#requirements

$ git clone https://github.com/oatpp/oatpp.git
$ cd oatpp\
$ MD build
$ cd build\

$ cmake ..
$ cmake --build . --target INSTALL
Hasan Eren Keskin
@herenkeskin_twitter

Hi everyone,

I want to send a file from client to server.
For example, I have a notification report file. And I want to send it to server from my application.
I'm currently using a download file from server in this link:
https://oatpp.io/docs/features/upload-file/
But I want to reverse this.

How can I do that?

API_CALL("POST", "FileUpload", fileUpload, BODY_STRING(String, body));

I can upload file as a string but I don't want to do this. I want to send all file.

oat++
@oatpp_io_twitter

Hello @herenkeskin_twitter ,

Please find my answer here - oatpp/oatpp#632

4 replies
FreddieTheCat
@ReturnHttp418
Hi, does anyone know how to return only a vector of strings instead of dto with SQL as select field_A from table? I tried to use oatpp::Vector<oatpp:String> when getting the query result and return it, but got Invalid result container type error.
Leonardo Rodríguez
@leorl14_twitter
Hello, does oatpp support SSE?
oat++
@oatpp_io_twitter

Hello @ReturnHttp418 ,

Hi, does anyone know how to return only a vector of strings instead of dto with SQL as select field_A from table? I tried to use oatpp::Vector<oatpp:String> when getting the query result and return it, but got Invalid result container type error.

auto dataset = res->fetch<Vector<Vector<String>>>();
auto firstRow = dataset[0];

The fetch method always returns a set of rows. That's why the root container is Vector.
Then, each row you can interpret as a DTO, as a Map/PairList or as a Vector/List/Set.

In this particular case - you have a Vector of rows represented as a Vector<Strings>.

3 replies
oat++
@oatpp_io_twitter

Hello @leorl14_twitter ,

Yes, oatpp does support SSE.
For this, you have to use a StreamingBody - for streaming response. Then just send messages in the proper format.

1 reply
James Kent
@captainjkent_twitter

Hello @erik9631 ,

oatpp ORM is a lower-level solution than Hibernate, but also it gives you more control over things.
You have to manage relations between tables manually on your own.

Here is the pseudo-code example of the DBClient - how to insert such an object:

class MyDbClient : public oatpp::orm::DbClient {
public:


  QUERY(insertProduct, ...)

  QUERY(insertProductItem, ..., 
        PARAM(oatpp::Int32, productId), 
        PARAM(oatpp::Object<ItemDto>, item))

  void insertProductAndItems(const oatpp::Object<ProductDTO>& dto) {

    auto transaction = client.beginTransaction();

    insertProduct(dto, transaction.getConnection());

    productId = <id of inserted product>;

    for(auto& item : *dto->items) {
      insertProductItem(productId, item, transaction.getConnection());
    }

    transaction.commit();

  }

};

I was wondering with the above code snippet, where it states to get the id of the inserted product. Can I do this by getting the last inserted row? Or is the row only created after committing? If that's the case, what would be the recommended way to get the id?

oat++
@oatpp_io_twitter

Hello @captainjkent_twitter ,

Getting Id of the inserted item differs depending on the exact Database

1 reply
James Kent
@captainjkent_twitter

I'm trying to get the IP from the request using the following:

auto& context = request->getConnection()->getInputStreamContext();
auto const& ipAddress = context.getProperties().getAll().at("peer_address").getData();

This throws me an error as peer_address doesn't exist. When I Take a look at the properties, I see that it is completely empty. Any idea what can cause this?

Emreiris
@Emreiris
Hello, how can I send files over REST API? I want to send log files when /logs GET request is received. Examples on oatpp website are focused on receiving files. But how can I do the reverse?
oat++
@oatpp_io_twitter

Hello @captainjkent_twitter ,

I'm trying to get the IP from the request using the following

You have to enable it in your connection provider:
https://github.com/oatpp/oatpp/blob/master/src/oatpp/network/tcp/server/ConnectionProvider.hpp#L117

set useExtendedConnections = true

1 reply

Hello @Emreiris ,

Hello, how can I send files over REST API? I want to send log files when /logs GET request is received. Examples on oatpp website are focused on receiving files. But how can I do the reverse?

https://github.com/oatpp/oatpp/issues/632#issuecomment-1264751622

Dmitrii
@DmitriiBurnaev

Hello,
There are 2 questions:
1)
class JwksClient : public oatpp::web::client::ApiClient {
public:

include OATPP_CODEGEN_BEGIN(ApiClient)

API_CLIENT_INIT(JwksClient)
API_CALL("GET", "/", doGet)

include OATPP_CODEGEN_END(ApiClient)

};

auto connectionProvider = tcp::client::ConnectionProvider::createShared({ "127.0.0.1", 8183});
auto requestExecutor = client::HttpRequestExecutor::createShared(connectionProvider);
auto objectMapper = json::mapping::ObjectMapper::createShared();
auto _client = JwksClient::createShared(requestExecutor, objectMapper);
auto j = _client->doGet();
std::cout << j->getStatusCode() << std::endl;
std::cout << *j->readBodyToString() << std::endl;

I have local service on 127.0.0.1:8183, try to GET on "/". Constantly receive 301 status code.
When make curl -X GET "127.0.0.1:8183/", everything is ok. Also created small Go service, it receives data without problem.
If I change 127.0.0.1:8183 to "httpbin.org", 80 , everything works properly as well.
"localhost", "0.0.0.0" do not help me either.
What do I wrong with local address?
2) I have a service and use swagger endpoint to send requests. Is it possible add "header" field in endpoint declaration such way that it would be available for filling by swagger page?

Thank you in advance!

Dmitrii
@DmitriiBurnaev
Unfortunately, I cannot edit the previous message. I simplified code and put it in your example project.
#include "oatpp-curl/RequestExecutor.hpp"

#include "oatpp/web/client/HttpRequestExecutor.hpp"
#include "oatpp/network/tcp/client/ConnectionProvider.hpp"

#include "oatpp/web/client/ApiClient.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"

#include <iostream>

class DemoApiClient : public oatpp::web::client::ApiClient {
#include OATPP_CODEGEN_BEGIN(ApiClient)
  API_CLIENT_INIT(DemoApiClient)
  API_CALL("GET", "/", doGet)
#include OATPP_CODEGEN_END(ApiClient)
};

std::shared_ptr<oatpp::web::client::RequestExecutor> createOatppExecutor() {
  OATPP_LOGD("App", "Using Oat++ native HttpRequestExecutor.");
  auto connectionProvider = oatpp::network::tcp::client::ConnectionProvider::createShared({"127.0.0.1", 8183});
  return oatpp::web::client::HttpRequestExecutor::createShared(connectionProvider);
}

void run(){
  auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
  auto requestExecutor = createOatppExecutor();   // <-- Always use oatpp native executor where's possible.
  auto client = DemoApiClient::createShared(requestExecutor, objectMapper);

 std::cout << *client->doGet()->readBodyToString() << std::endl;
}

int main(int argc, const char * argv[]) {
  run();
}
oat++
@oatpp_io_twitter

Hello @DmitriiBurnaev ,

I have local service on 127.0.0.1:8183, try to GET on "/". Constantly receive 301 status code.

301 is moved permanently redirect. Oat++ doesn't automatically follow redirects. So you have to read the response and check the Location header to see the destination URL.

I have a service and use swagger endpoint to send requests. Is it possible add "header" field in endpoint declaration such way that it would be available for filling by swagger page?

Sure:

  ENDPOINT("GET", "withHeader", getWithHeader,
           HEADER(String, myHeader, "X-MyHeader")) //<--- This header will be displayed in Swagger page
  {
    return createResponse(Status::CODE_200, "OK");
  }
Nimish Mistry
@nimishmistry

I have this peculiar issue on oatpp server running on Windows. I'm sending a POST request from a .NET based HttpClient. Though the server endpoint returns correctly, the client function just hangs on the SendAsync call. The GetAsync runs just fine

Anyone encountered such an issue?

var tmpClient = new HttpClient();

var restUrl = $"http://localhost:8001/api/v1/dosomething";

var tmpRequest = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri(restUrl),
    Content = new StringContent(param) { Headers = { ContentType = new MediaTypeHeaderValue("text/plain") } },
};

return tmpClient.SendAsync(tmpRequest);
oat++
@oatpp_io_twitter

@nimishmistry ,

Most probably you are not reading body in oatpp server endpoint. And your .NET client waits until body is read.

Please post your endpoint code here