My proxy is configured correctly because, apart from the swarm agent, all other programs have successful connections
No. All other programs having successful connections does not guarantee that your proxy server is configured correctly. For example, Jenkins Remoting (and therefore Swarm) requires the ability to issue a CONNECT to a non-standard port, but some proxy servers (including Squid) deny CONNECT to ports other than port 443 by default. The point is, as I explained in my previous comment, that you need to check your proxy server logs for access denied messages, then configure your proxy server appropriately.