Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++ Networking] Http Nginx Keepalives #1651

Open
halx99 opened this issue Feb 4, 2024 Discussed in #612 · 0 comments
Open

[C++ Networking] Http Nginx Keepalives #1651

halx99 opened this issue Feb 4, 2024 Discussed in #612 · 0 comments
Labels
help wanted Extra attention is needed pinned
Milestone

Comments

@halx99
Copy link
Collaborator

halx99 commented Feb 4, 2024

Discussed in #612

Originally posted by DelinWorks March 31, 2022
I've set up an nginx server so I can host my login and signup system for this game and load the scores

Problem is that I've told nginx to keep the connections open for 120 seconds and it seems that whenever I send a request through my game the connection gets released and not kept alive. I've known this because chrome keeps the connection for exactly 120 secs using NetLimiter and when I inspect the game using NetLimiter the game just releases the connection as soon as the request is done

Why would I keep connections alive? it's because when you're working with multiplayer games you want to minimize the amount of tcp connections to be initialized. so that the server and the game feel fast

As you can see chrome keeps the connection alive as said in nginx config:

image

But the game keeps dropping the connection as soon as the request is finished:

image

So how would you go about implementing this in c++ ? (Keeping connections alive for later use)

I initiate connections this way

auto request = new (std::nothrow) network::HttpRequest();
request->setRequestType(network::HttpRequest::Type::GET);
request->setUrl("https://delingames.xyz/accounts/load_score.php?uid=1");
request->setResponseCallback([&](network::HttpClient* client, network::HttpResponse* response) {
    if (response->isSucceed()) {
        // process request from server
    });
network::HttpClient::getInstance()->send(request);
@halx99 halx99 added the help wanted Extra attention is needed label Feb 4, 2024
@halx99 halx99 added this to the next milestone Feb 4, 2024
@halx99 halx99 added the pinned label Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed pinned
Projects
None yet
Development

No branches or pull requests

1 participant