Merge pull request #266 from limingxinleo/dev

Fixed timeout when produce a amqp message.
This commit is contained in:
李铭昕 2019-07-24 17:24:07 +08:00 committed by GitHub
commit a520f239fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -1,5 +1,9 @@
# v1.0.7 - TBD # v1.0.7 - TBD
## Fixed
- [#266](https://github.com/hyperf-cloud/hyperf/pull/266) Fixed timeout when produce a amqp message.
# v1.0.6 - 2019-07-24 # v1.0.6 - 2019-07-24
## Added ## Added

View File

@ -139,7 +139,7 @@ class Connection extends BaseConnection implements ConnectionInterface
$class = AMQPSwooleConnection::class; $class = AMQPSwooleConnection::class;
} }
$this->lastHeartbeatTime = 0; $this->lastHeartbeatTime = microtime(true);
return new $class($this->config['host'] ?? 'localhost', $this->config['port'] ?? 5672, $this->config['user'] ?? 'guest', $this->config['password'] ?? 'guest', $this->config['vhost'] ?? '/', $this->params->isInsist(), $this->params->getLoginMethod(), $this->params->getLoginResponse(), $this->params->getLocale(), $this->params->getConnectionTimeout(), $this->params->getReadWriteTimeout(), $this->params->getContext(), $this->params->isKeepalive(), $this->params->getHeartbeat()); return new $class($this->config['host'] ?? 'localhost', $this->config['port'] ?? 5672, $this->config['user'] ?? 'guest', $this->config['password'] ?? 'guest', $this->config['vhost'] ?? '/', $this->params->isInsist(), $this->params->getLoginMethod(), $this->params->getLoginResponse(), $this->params->getLocale(), $this->params->getConnectionTimeout(), $this->params->getReadWriteTimeout(), $this->params->getContext(), $this->params->isKeepalive(), $this->params->getHeartbeat());
} }
@ -149,13 +149,8 @@ class Connection extends BaseConnection implements ConnectionInterface
return false; return false;
} }
$lastHeartbeatTime = $this->lastHeartbeatTime; if (microtime(true) - $this->lastHeartbeatTime > $this->params->getHeartbeat()) {
$currentTime = microtime(true); return true;
if ($lastHeartbeatTime && $lastHeartbeatTime > 0) {
if ($currentTime - $lastHeartbeatTime > $this->params->getHeartbeat()) {
return true;
}
} }
return false; return false;