Skip to content

Is it possible shared an event loop (libuv) between uWebSockets and my backend ? #1833

Discussion options

You must be logged in to vote

I figured my problem. I was compiling my POC with the WITH_LIBUV=1 flag and linking with the uWesbSockets lib instead of compiling the uWesbSockets lib with the WITH_LIBUV=1 and linking it to my binary.
So the loop used by the uWebSockets lib was not the libuv loop, but the default one.

If someone read my discution and want to combine an uWebSockets server with an existing libuv loop, here is an example :

int main() {
  uWS::Loop::get(uvw::loop::get_default()->raw());
  auto app = std::make_unique<uWS::App>();

  app->get("/health", [&](auto* res, auto* req) {
    fmt::print("Url {}, Method {}\n", req->getUrl(), req->getMethod());

    res->onData([res](std::string_view data, bool isLast)…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@theo-issarni-wmx
Comment options

@theo-issarni-wmx
Comment options

Answer selected by theo-issarni-wmx
@uNetworkingAB
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants