Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 00:27
    lganzzzo closed #549
  • 00:26
    lganzzzo commented #549
  • 00:26

    lganzzzo on windows_fix_dual_stack_socket

    (compare)

  • 00:26

    lganzzzo on master

    tcp::server::ConnectionProvider… Merge pull request #550 from oa… (compare)

  • 00:26
    lganzzzo closed #550
  • 00:11
    lganzzzo opened #550
  • 00:11

    lganzzzo on windows_fix_dual_stack_socket

    tcp::server::ConnectionProvider… (compare)

  • Jan 16 23:55
    lganzzzo labeled #549
  • Jan 16 23:55
    lganzzzo assigned #549
  • Jan 16 23:55
    lganzzzo opened #549
  • Jan 15 04:16
    lganzzzo commented #547
  • Jan 15 04:15
    lganzzzo milestoned #547
  • Jan 15 04:15
    lganzzzo labeled #547
  • Jan 15 04:12
    lganzzzo commented #546
  • Jan 15 04:11
    lganzzzo commented #546
  • Jan 15 04:06
    ZizhengTai closed #548
  • Jan 15 04:06
    ZizhengTai commented #548
  • Jan 15 03:59
    lganzzzo labeled #546
  • Jan 15 03:54
    lganzzzo commented #548
  • Jan 15 01:01
    ZizhengTai opened #548
mmn
@mmn:matrix.org
[m]
What about objdump -a path/to/liboatpp.a?
AlexandreHURDYK
@AlexandreHURDYK
This one dumps a lot of stuff. Are you looking for a line in particular ?
mmn
@mmn:matrix.org
[m]
More like any one record.
I get for example
Pattern.cpp.o: tiedostomuoto elf64-x86-64
rw-r--r-- 0/0 417832 Jan 1 02:00 1970 Pattern.cpp.o
AlexandreHURDYK
@AlexandreHURDYK
Let's pick one .o entry at random then
Processor.cpp.o: format de fichier elf32-i386
rw-r--r-- 0/0 190588 Jan 1 01:00 1970 Processor.cpp.o
mmn
@mmn:matrix.org
[m]
yeah
AlexandreHURDYK
@AlexandreHURDYK
format de fichier means "file format"
mmn
@mmn:matrix.org
[m]
I know.
Je comprends.
This is the important thing: elf32-i386
So you didn't cross-compile it for (32bit) arm, you just built it for 32bit x86 architecture.
AlexandreHURDYK
@AlexandreHURDYK
Darn. So it was bad all along.
Ok so at least we know why it doesn't work now.
mmn
@mmn:matrix.org
[m]
Yeah. So you have to somehow convince cmake to use your cross-compiling (for armhf) toolchain instead of your native (x86_64) one. Maybe the line source /opt/phytec-yogurt/BSP-Yocto-i.MX6-PD18.1.1/environment-setup-cortexa9hf-neon-phytec-linux-gnueabi should have done something like that, but apparently it didn't.
AlexandreHURDYK
@AlexandreHURDYK
Alright. At least now I know what went wrong. Thanks for the troubleshooting. I'll try these links out. :)
Fabrice Aeschbacher
@aeschbacher
@AlexandreHURDYK BTW if you're using Yocto (and not an external toolchain) oat++ builds just fine with
# PN, SRC_URI et all as usual , then
inherit cmake

FILES_${PN}-staticdev += "${libdir}/*"

EXTRA_OECMAKE = "\
  -DCMAKE_BUILD_TYPE=Release \
  -DOATPP_BUILD_TESTS=OFF \
mmn
@mmn:matrix.org
[m]
Hi, I'm trying to somehow get into Oat++, but I am honestly quite struggling with the documentation. Oat++ uses macros a lot for a C++ library (maybe even more than what I am used to from C where one does not have templates etc.), and at least to me function of many of them is far from obvious without looking into the code.
My point is that it would REALLY help if the documentation provided at least a high-level overview of how does the Oat++ macro system work and what do the macros actually do (mainly in the ORM/DTO and DI parts).
The macros are used throughout the examples, but AFAIK it isn't explained anywhere what they do.
oat++
@oatpp_io_twitter

Hello @mmn:matrix.org ,

The macros are used throughout the examples, but AFAIK it isn't explained anywhere what they do.

You can find docs on ORM, DTO, and other oatpp components here on the website:

If you feel that those docs aren't enough - please file an issue on Github - in oatpp website repo - https://github.com/oatpp/website

Also, please feel free to ping me here in case you need some deeper technical details on how those macros work.
Jeremy Guinn
@JeremyGuinn
Has there been any consideration for adding support for the http/2 spec and eventually http/3?
AlexandreHURDYK
@AlexandreHURDYK

Hello.

I'm trying to send an API call client side from a thread but I my client crashes everytime I call tthe API function. There's probably something I'm missing or not doing right. I'm going to post a small reproducible example :

AlexandreHURDYK
@AlexandreHURDYK
//My client class
class VoucherClient : public oatpp::web::client::ApiClient
{
    #include OATPP_CODEGEN_BEGIN(ApiClient) 
    API_CLIENT_INIT(VoucherClient)
        API_CALL_ASYNC("POST", "/", getRoot)
        API_CALL("POST", "/connect", connect, BODY_STRING(String, ip))
    #include OATPP_CODEGEN_END(ApiClient) 
};

//My API call function :
void funcCall(shared_ptr<VoucherClient> client)
{
                                cout << "[Connect] Calling the server..." << endl;
                auto data = client->connect("127.0.0.1")->readBodyToString(); //Crash dans le thread
                OATPP_LOGD("CLIENT", "[connect] data='%s'", data->c_str());
}

//My run function :
void run()
{
           cout << "Creating objectmapper" << endl;
    auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
    cout << "Creating requestexecutor" << endl;
    auto requestExecutor = createOatppExecutor();
    cout << "Creating client" << endl;
    auto client = VoucherClient::createShared(requestExecutor, objectMapper);
    std::thread th(client);
}

//My main function :
int main()
{
    oatpp::base::Environment::init();
    printHelp();
    run();
    oatpp::base::Environment::destroy();
    cout << "Press any key to close the program" << endl;
    _getch();
    return 0;
}
My actual app is actually much bigger than that. This is just a minimal example.
I've noticed that I need to join my thread un order to allow my code to work with th.join(), but my goal in the end is to see if my server can manage being sent another request before it sends an answer to my precedent request.
And using join would prevent me from using the main thread until the child thread is done working.
AlexandreHURDYK
@AlexandreHURDYK
Ok nevermind I've found what I'm doing wrong.
Actually my issue is just solved by using the detach() function.
This was more of a windows thread related issue rather than an oat++ issue.
Sorry for the wall of code. :')
shijiantouzouyiqie
@shijiantouzouyiqie
The browser and server are upgraded to websocket protocol and the connection is established successfully. Does the server support sending data actively?
What solution should be set if you want the server to actively send data information after the connection is established?
Nikola Radovanovic
@nikoladsp

Hi,

I am evaluating simple/efficient and dependency-lite framework to create REST C++ backend for WEB app frontend which will be in typescript and PostgreSql as database.

So short question is: am I in the right place? :)

Also, I would like to have some Swagger that can "use" (read: serialize/load) to/from JSON and C++ model classes. This is not necessary, but nice bonus.

I tried PHP, but I really don't feel comfortable with it. Python is bit slow for my taste, so maybe its time to get back home to the one I love - C++.

Thanks in advance

Peter Ritter
@peterritter
I got a basic question. Is an Oat++ server a standalone executable or does it require a web server to run in production, with the custom logic running as CGI or .dll or something like that? I have a custom application in mind and I need it to be easy to run and install.
oat++
@oatpp_io_twitter

Has there been any consideration for adding support for the http/2 spec and eventually http/3?

@JeremyGuinn , http2/3 isn't a priority for oatpp at the moment.
The main reason is that http2/3 are mainly designed for better multimedia content delivery - serving APIs is arguably more effective with HTTP 1.1 (depends on the application)

However, I think it should be possible to integrate oatpp with ex.: h2o server

The browser and server are upgraded to websocket protocol and the connection is established successfully. Does the server support sending data actively?
What solution should be set if you want the server to actively send data information after the connection is established?

Hey @shijiantouzouyiqie , sure - when a client is connected to the server, you'r getting the WebSocket object representing the client -
https://github.com/oatpp/example-websocket/blob/master/server/src/websocket/WSListener.cpp#L43.
Then you can write data to that socket, using sendOneFrameText or sendOneFrameBinary methods.

oat++
@oatpp_io_twitter

Hi,
I am evaluating simple/efficient and dependency-lite framework to create REST C++ backend for WEB app frontend which will be in typescript and PostgreSql as database.
So short question is: am I in the right place? :)
Also, I would like to have some Swagger that can "use" (read: serialize/load) to/from JSON and C++ model classes. This is not necessary, but nice bonus.

Hello @nikoladsp , yes, you are in the right place :)
Please check-out this example project - https://github.com/oatpp/example-postgresql
It's basically a web-service which talks to postgres, and has swagger-ui

1 reply

I got a basic question. Is an Oat++ server a standalone executable or does it require a web server to run in production, with the custom logic running as CGI or .dll or something like that? I have a custom application in mind and I need it to be easy to run and install.

Hello @peterritter , yes, Oat++ server is a standalone executable.

shijiantouzouyiqie
@shijiantouzouyiqie
@oatpp_io_twitter Hey, in the "onaftercreate()" function, what other parameters need to be set to write when "socket. Sendoneframetext();" is applied?
void WSInstanceListener::onAfterCreate(const oatpp::websocket::WebSocket& socket, const std::shared_ptr<const ParameterMap>& params) {

  socket.sendOneFrameText("Hello");

  SOCKETS ++;
  OATPP_LOGD(TAG, "New Incoming Connection. Connection count=%d", SOCKETS.load());

  /* In this particular case we create one WSListener per each connection */
  /* Which may be redundant in many cases */
  socket.setListener(std::make_shared<WSListener>());
}

 I |2021-12-01 14:35:37 1638340537126253| MyApp:Server running on port 8000
 D |2021-12-01 14:35:39 1638340539806813| Server_WSInstanceListener:New Incoming Connection. Connection count=1
 D |2021-12-01 14:35:39 1638340539876373| [oatpp::web::protocol::websocket::WebSocket::listen()]:Unhandled error occurred. Message='[oatpp::web::protocol::websocket::WebSocket::readFrameHeader()]: Error reading frame header'
 D |2021-12-01 14:35:39 1638340539876411| Server_WSInstanceListener:Connection closed. Connection count=0
oat++
@oatpp_io_twitter

Hey @shijiantouzouyiqie ,

Looks like at this point the WS connection appears to be not fully established (and it's a bug).
So you don't want to write to the client socket directly from this method. Instead you can use a separate thread:

void WSInstanceListener::onAfterCreate(const oatpp::websocket::WebSocket& socket, const std::shared_ptr<const ParameterMap>& params) {

  SOCKETS ++;
  OATPP_LOGD(TAG, "New Incoming Connection. Connection count=%d", SOCKETS.load());

  /* In this particular case we create one WSListener per each connection */
  /* Which may be redundant in many cases */
  socket.setListener(std::make_shared<WSListener>());

  std::thread t([&socket]{
    socket.sendOneFrameText("Hello");
  });

  t.detach();

}

Please file an issue on Github. WS Connection should be fully established by the time WSInstanceListener::onAfterCreate method is called.

6 replies
shijiantouzouyiqie
@shijiantouzouyiqie
Websocket establishes a connection. At present, a single WS address sends a response. If it is a different WS address, how do you do it?
  ENDPOINT("GET", "ws", ws, REQUEST(std::shared_ptr<IncomingRequest>, request)) {
    return oatpp::websocket::Handshaker::serversideHandshake(request->getHeaders(), websocketConnectionHandler);
  };
oat++
@oatpp_io_twitter

Hey @shijiantouzouyiqie , do you mean that you want to connect on multiple WS endpoints?

Then you just create a different endpoint for that - rest is the same

6 replies
Fabrice Aeschbacher
@aeschbacher

Sometimes I need to check whether the request's Body is not empty. I do this using :

if (request->getHeaders().get(Header::CONTENT_LENGTH)) { 
    // body is not empty
}

but is this efficient, or is there a better way to test that ?

oat++
@oatpp_io_twitter
Hm, it's not the best way for sure - you may have a request with transfer-encoding: chunked in this case you have no Content-Length header
7 replies
So, you just want to check if body arrived empty, or you want to check if request contains no body?
It's a bit different states as per oatpp - since you can opt-out receiving body at all, and just return 400 or something
Zach
@acidtonic
I seen some talk about Phytec embedded boards a bit earlier. I have been pondering using them for some work as well, just curious if you like the platform/support/documentation? (hope it's not too off topic)