fpagliughi / sockpp

Modern C++ socket library.
BSD 3-Clause "New" or "Revised" License
769 stars 126 forks source link

Simultaneous TCP connections automatically closes #57

Closed jeffRTC closed 2 years ago

jeffRTC commented 2 years ago

@fpagliughi

Thank you for building this awesome library. I'm seeing this weird issue where if we start Simultaneous 2 TCP connections to the server, the sever issue RSTs and close the TCP connections, but this doesn't happen if we open like more than 2 simultaneous TCP connections at same time.

I'm using Ubuntu OS. I observe the same issue on the evpp library, but I don't think this is library specific.

I did compile with these flags too

-Wpedantic -Wthread-safety -Wall -Wextra -g -fsanitize=undefined -fsanitize=address -fsanitize=leak

But they detected nothing, and so is Valgrind

The following NodeJS script is used to send Simultaneous TCP connections. You don't need to write a HTTP server stack to test this, just the usual TCP code with do nothing while loop to keep socket from destructuring. I'm using 5 threads in the C++ server.

const request = require('request-promise');

async function main() {
    try {
        // 2 requests at same time fails
        const urls = [
            "https://YOUR_IP:PORT",
            "https://YOUR_IP:PORT",
        ]

        const requests = [];

        for(const url of urls) {
            requests.push(request.get(url));
        }

        let res = await Promise.race(requests);

    } catch (e) {
        console.log(e);
    }
}

main();

Please do let me know if you need the threaded wrapper that I wrote around your low level lib.

jeffRTC commented 2 years ago

Turns out that it's a firewall issue.