3

I built a PHP application to establish a TCP socket connection to a mail server (SMTP server) on port 25, using a proxy. Here the main part:

$context = [
    "http" => [
        "proxy" => "tcp://xx.xx.xx.xx:xxxx",
        "request_fulluri" => true 
        "header" => "Proxy-Authorization: Basic xxxxxxxxxxx"
    ]]
};

$connection = @stream_socket_client(
        address: "tcp://$mxHost:25",
        error_code: $errno,
        error_message: $errstr,
        timeout: 10,
        context: $context
);

I built the first version of the app as a Vanilla PHP with some Symfony components, and I run it using php -S localhost:8000 -t . and it works like a charm.

Then I decided to install Symfony, inside a Docker installation. Since I build a DDD/Clean Architecture application, it was easy to switch to a fully Symfony application.

But then the problems start.

It seems like inside Docker I cannot use stream_socket_client correctly, I always get a connection timeout (110).

At some point I added

    dns:  # Custom DNS settings
      - 8.8.8.8
      - 1.1.1.1

to my docker-compose.yml, and it worked for one day. The day after, it stopped to works and I started again to get connection timeout.

My knowledge about network is not so strong, so I need a help.

Can someone give me a tip, a suggestion, an idea to unblock this situation?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.