/** * @param PromiseInterface $promise */ protected function retry(PromiseInterface $promise) { if ($this->counter >= $this->params['retriesLimit']) { $promise->reject(new LazyException(new TimeoutException('No response was received during specified timeout.'))); } else { if ($this->params['retriesInterval'] > 0) { $this->counter++; $this->channel->getLoop()->addTimer($this->params['retriesInterval'], function () use($promise) { $this->send($promise); }); } else { $this->counter++; $this->channel->getLoop()->afterTick(function () use($promise) { $this->send($promise); }); } } }