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

randomly session not created, port 9515 is already in use or disconnected. #646

Open
lektura0bandyta opened this issue Oct 5, 2024 · 2 comments

Comments

@lektura0bandyta
Copy link

Hi, I'm running panther crawler with chrome client on AWS Lambda.
It starts by cron few times per day and every time on own new instance but randomly it throw few errors on creating client.
Does anyone now where should I look to prevent it?

My arguments for client are simple like below:

'--headless',
'--no-sandbox',
'--window-size=1280x720',
'--single-process',
'--disable-gpu',

errors:
The port 9515 is already in use.

disconnected: unable to send message to renderer (failed to check if window was closed: disconnected: not connected to DevTools) (Session info: chrome-headless-shell=126.0.6478.112)

session not created from chrome not reachable

@Chris53897
Copy link

This works for us on bare metal servers. Could you please check if it works for AWS Lambda too?

private function getAvailablePort(): int
    {
        // When providing '0' as port, the OS picks a random available port
        $socket = socket_create_listen(0);

        socket_getsockname($socket, $address, $port);

        socket_close($socket);

        return $port;
    }

...

$availablePort = getAvailablePort();

$this->browser = Client::createChromeClient(
            options: [
                'port' => $availablePort,
            ],
        );

@Chris53897
Copy link

Maybe this can solved in general, to allow "random" in PANTHER_WEB_SERVER_PORT
https://github.com/search?q=repo%3Asymfony%2Fpanther%20PANTHER_WEB_SERVER_PORT&type=code

But of course this can lead to sideeffects if there are port-collisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants