8000 DNS Issue when running messenger consume workers using symfony-cli · Issue #534 · symfony-cli/symfony-cli · GitHub
[go: up one dir, main page]

Skip to content

DNS Issue when running messenger consume workers using symfony-cli #534

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

Open
amenophis opened this issue Nov 3, 2024 · 6 comments
Open

Comments

@amenophis
Copy link

Hello 👋

I am trying to use symfony cli workers to run my symfony messenger consume commands locally.
Some on my messenger handler use symfony/http-client to make external call, but none of them work because of DNS issue.
When I run manually the consume commands from my terminal, it works without issues.

Do you have an idea why ?

Thanks 🙏

@amenophis
Copy link
Author
amenophis commented Nov 3, 2024

I found a workaround to make it work.

My current config is this one (not working)

workers:
    docker_compose: ~
    messenger_consume_command_outbox:
        cmd: ['symfony', 'console', 'messenger:consume', 'command_outbox']
        watch: ['config', 'src', 'vendor']
    messenger_consume_command_async:
        cmd: ['symfony', 'console', 'messenger:consume', 'command_async']
        watch: ['config', 'src', 'vendor']

It work if I replace cmd: ['symfony', 'console', ...] by cmd: ['bin/console', ...]

Any idea why using symfony console didn't work ?

Edit: Little precision, it work when i run manually using bin/console or symfony console

@tucksaun
Copy link
Member
tucksaun commented Nov 5, 2024

Hello @amenophis

could you provide the exact logs of the HttpClient failures?

Could you also try to run symfony console messenger:consume command_outbox directly and see if the failure is happening? thanks

8000

@kbond
Copy link
kbond commented Mar 3, 2025

Hey @tucksaun, I think I'm having the same issue - or very similar.

Here's the error I get (only when running messenger:consume as a worker).

messenger.CRITICAL: Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Removing from transport after 3 retries. Error: "Handling "Symfony\Component\Mailer\Messenger\SendEmailMessage" failed: Connection could not be established with host "sandbox.smtp.mailtrap.io:2525": stream_socket_client(): php_network_getaddresses: getaddrinfo for sandbox.smtp.mailtrap.io failed: nodename nor servname provided, or not known" {"class":"Symfony\Component\Mailer\Messenger\SendEmailMessage","message_id":80,"retryCount":3,"error":"Handling "Symfony\Component\Mailer\Messenger\SendEmailMessage" failed: Connection could not be established with host "sandbox.smtp.mailtrap.io:2525": stream_socket_client(): php_network_getaddresses: getaddrinfo for sandbox.smtp.mailtrap.io failed: nodename nor servname provided, or not known","exception":"[object] (Symfony\Component\Messenger\Exception\HandlerFailedException(code: 0): Handling "Symfony\Component\Mailer\Messenger\SendEmailMessage" failed: Connection could not be established with host "sandbox.smtp.mailtrap.io:2525": stream_socket_client(): php_network_getaddresses: getaddrinfo for sandbox.smtp.mailtrap.io failed: nodename nor servname provided, or not known at /vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php:124)\n[previous exception] [object] (Symfony\Component\Mailer\Exception\TransportException(code: 0): Connection could not be established with host "sandbox.smtp.mailtrap.io:2525": stream_socket_client(): php_network_getaddresses: getaddrinfo for sandbox.smtp.mailtrap.io failed: nodename nor servname provided, or not known at /vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php:154)"} []

I think this is a DNS issue.

It work if I replace cmd: ['symfony', 'console', ...] by cmd: ['bin/console', ...]

This workaround doesn't seem to work for me.

it work when i run manually using bin/console or symfony console

Same for me. It works as expected when running messenger:consume manually in a terminal with either bin/console or symfony console.

@tucksaun
Copy link
Member
tucksaun commented Mar 4, 2025

@kbond thanks for the info!

but that is strange as we don't/can't really change DNS settings IIRC.

could you share a small repro (even privately) with me?

@kbond
Copy link
kbond commented Mar 4, 2025

Here's a reproducer: https://github.com/kbond/cli-reproducer

I'm using http-client to make a connection and the error is ~ symfony/http-client/Internal/DnsCache.php: Failed to open stream: Too many open files. For sure DNS related.

I found #497 which looks related?

For your check here: #497 (comment), when the messenger:consume worker is running I see:

10081 symfony 90906
10075 symfony 90922

For reference, when I don't have the worker running (just the webserver), I see:

  10 symfony 91076

@kbond
Copy link
kbond commented Mar 4, 2025

Ah!

It occurred to me that the "too many files" issue was related to the worker watch. I was watching vendor, which has 1000's of files. Sure enough, when I exclude vendor, my reproducer works and my original issue... (and the number of files for the symfony process is dramatically reduced)

Still not sure why it this produced DNS-related issues though.

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

No branches or pull requests

3 participants
0