diff --git a/src/IPub/MQTTClient/Client/Client.php b/src/IPub/MQTTClient/Client/Client.php index 59f4fcd..559b33b 100644 --- a/src/IPub/MQTTClient/Client/Client.php +++ b/src/IPub/MQTTClient/Client/Client.php @@ -22,7 +22,6 @@ use Nette; use React\EventLoop; -use React\Dns; use React\Promise; use React\Socket; use React\Stream; @@ -232,8 +231,6 @@ public function __construct( $this->loop = $eventLoop; $this->configuration = $configuration; - $this->createConnector(); - $this->parser = $parser; if ($this->parser === NULL) { @@ -259,8 +256,6 @@ public function setLoop(EventLoop\LoopInterface $loop) : void if (!$this->isConnected && !$this->isConnecting) { $this->loop = $loop; - $this->createConnector(); - } else { throw new Exceptions\LogicException('Connection is already established. React event loop could not be changed.'); } @@ -325,6 +320,8 @@ public function connect() : Promise\ExtendedPromiseInterface return new Promise\RejectedPromise(new Exceptions\LogicException('The client is already connected.')); } + $this->createConnector(); + $this->onStart(); $this->isConnecting = TRUE; @@ -863,15 +860,10 @@ private function finishFlow(Flow\Envelope $flow) : void */ private function createConnector() : void { - $this->connector = new Socket\TcpConnector($this->loop); - - if ($this->configuration->isDNSEnabled()) { - $dnsResolverFactory = new Dns\Resolver\Factory; - - $this->connector = new Socket\DnsConnector($this->connector, $dnsResolverFactory->createCached($this->configuration->getDNSAddress(), $this->loop)); - } + $this->connector = new Socket\Connector($this->loop); if ($this->configuration->isSSLEnabled()) { + $this->connector = new Socket\TcpConnector($this->loop); $this->connector = new Socket\SecureConnector($this->connector, $this->loop, $this->configuration->getSSLConfiguration()); } } diff --git a/src/IPub/MQTTClient/Configuration/Broker.php b/src/IPub/MQTTClient/Configuration/Broker.php index cdd0f08..6fe67bb 100644 --- a/src/IPub/MQTTClient/Configuration/Broker.php +++ b/src/IPub/MQTTClient/Configuration/Broker.php @@ -50,16 +50,6 @@ final class Broker */ private $address; - /** - * @var bool - */ - private $enableDNS = TRUE; - - /** - * @var string - */ - private $dnsAddress; - /** * @var bool */ @@ -79,8 +69,6 @@ final class Broker * @param string|NULL $httpHost * @param int $port * @param string|NULL $address - * @param bool $enableDNS - * @param string $dnsAddress * @param bool $enableSSL * @param array $sslSettings * @param Connection $connection @@ -89,8 +77,6 @@ public function __construct( string $httpHost = NULL, int $port = 1883, string $address = NULL, - bool $enableDNS = TRUE, - string $dnsAddress = '8.8.8.8', bool $enableSSL = FALSE, array $sslSettings = [], Connection $connection @@ -98,8 +84,6 @@ public function __construct( $this->httpHost = $httpHost; $this->port = $port; $this->address = $address; - $this->enableDNS = $enableDNS; - $this->dnsAddress = $dnsAddress; $this->enableSSL = $enableSSL; $this->sslSettings = $sslSettings; $this->connection = $connection; @@ -146,22 +130,6 @@ public function getAddress() : ?string return $this->address; } - /** - * @return bool - */ - public function isDNSEnabled() : bool - { - return $this->enableDNS; - } - - /** - * @return string - */ - public function getDNSAddress() : string - { - return $this->dnsAddress; - } - /** * @return bool */ diff --git a/src/IPub/MQTTClient/DI/MQTTClientExtension.php b/src/IPub/MQTTClient/DI/MQTTClientExtension.php index b5a1e47..7bea1e4 100644 --- a/src/IPub/MQTTClient/DI/MQTTClientExtension.php +++ b/src/IPub/MQTTClient/DI/MQTTClientExtension.php @@ -53,10 +53,6 @@ public function getConfigSchema() : Schema\Schema 'httpHost' => Schema\Expect::string()->nullable(), 'port' => Schema\Expect::int(1883), 'address' => Schema\Expect::string('127.0.0.1'), - 'dns' => Schema\Expect::structure([ - 'enable' => Schema\Expect::bool(TRUE), - 'address' => Schema\Expect::string('8.8.8.8'), - ]), 'secured' => Schema\Expect::structure([ 'enable' => Schema\Expect::bool(FALSE), 'sslSettings' => Schema\Expect::array([]), @@ -114,8 +110,6 @@ public function loadConfiguration() 'httpHost' => $configuration->broker->httpHost, 'port' => $configuration->broker->port, 'address' => $configuration->broker->address, - 'enableDNS' => $configuration->broker->dns->enable, - 'dnsAddress' => $configuration->broker->dns->address, 'enableSSL' => $configuration->broker->secured->enable, 'sslSettings' => $configuration->broker->secured->sslSettings, $connection,