@@ -333,6 +333,7 @@ public async Task<StreamInfo> StreamInfo(string streamName)
333333 // when theres 1 endpoint and an address resolver, there could be a cluster behind a load balancer
334334 var forceLocalHost = false ;
335335 var localPort = 0 ;
336+ var localHostOrAddress = "" ;
336337 if ( _clientParameters . Endpoints . Count == 1 &&
337338 _clientParameters . AddressResolver is null )
338339 {
@@ -342,10 +343,12 @@ public async Task<StreamInfo> StreamInfo(string streamName)
342343 case DnsEndPoint { Host : "localhost" } dnsEndPoint :
343344 forceLocalHost = true ;
344345 localPort = dnsEndPoint . Port ;
346+ localHostOrAddress = dnsEndPoint . Host ;
345347 break ;
346- case IPEndPoint ipEndPoint when Equals ( ipEndPoint . Address , IPAddress . Loopback ) :
348+ case IPEndPoint ipEndPoint when IPAddress . IsLoopback ( ipEndPoint . Address ) :
347349 forceLocalHost = true ;
348350 localPort = ipEndPoint . Port ;
351+ localHostOrAddress = ipEndPoint . Address . ToString ( ) ;
349352 break ;
350353 }
351354 }
@@ -354,7 +357,7 @@ public async Task<StreamInfo> StreamInfo(string streamName)
354357 if ( forceLocalHost )
355358 {
356359 // craft the metadata response to force using localhost
357- var leader = new Broker ( "localhost" , ( uint ) localPort ) ;
360+ var leader = new Broker ( localHostOrAddress , ( uint ) localPort ) ;
358361 metaStreamInfo = new StreamInfo ( streamName , ResponseCode . Ok , leader ,
359362 new List < Broker > ( 1 ) { leader } ) ;
360363 }
0 commit comments