Skip to content

Commit

Permalink
Update SniffingConnectionPool.php
Browse files Browse the repository at this point in the history
These changes are imported from :
Fix parsing of NodesInfo for Sniffing
Closes elastic#629 and elastic#648
for sniffing to work properly.

elastic@c0ed43c
  • Loading branch information
ankushgup2a authored Feb 26, 2018
1 parent c57db9d commit 66bffa8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Elasticsearch/ConnectionPool/SniffingConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ private function sniffConnection(Connection $connection)

private function parseClusterState($transportSchema, $nodeInfo)
{
$pattern = '/\/([^:]*):([0-9]+)\]/';
$pattern = '/([^:]*):([0-9]+)/';
$schemaAddress = $transportSchema . '_address';
$hosts = array();

foreach ($nodeInfo['nodes'] as $node) {
if (isset($node[$schemaAddress]) === true) {
if (preg_match($pattern, $node[$schemaAddress], $match) === 1) {
if (isset($node['http']) === true && isset($node['http']['publish_address']) === true) {
if (preg_match($pattern, $node['http']['publish_address'], $match) === 1) {
$hosts[] = array(
'host' => $match[1],
'port' => (int) $match[2],
Expand Down

0 comments on commit 66bffa8

Please sign in to comment.