Skip to content

TcpStats.GetStates() crashes on Azure #5176

@RPM1984

Description

@RPM1984

NEST/Elasticsearch.Net version: 7.10.1

Elasticsearch version: 7.2.0

Description of the problem including expected versus actual behavior:
On Azure, when attempting to connect to my cluster, I receive this error for all requests when .EnableDebugMode() is set on ConnectionSettings:

message: "Access is denied.",
type: "System.Net.NetworkInformation.NetworkInformationException",
raw: "System.Net.NetworkInformation.NetworkInformationException (5): Access is denied. 
at System.Net.NetworkInformation.SystemIPGlobalProperties.GetAllTcpConnections() 
at System.Net.NetworkInformation.SystemIPGlobalProperties.GetActiveTcpConnections() 
at Elasticsearch.Net.Diagnostics.TcpStats.GetStates() 
at Elasticsearch.Net.HttpConnection.RequestAsync[TResponse](RequestData requestData, CancellationToken cancellationToken) at Elasticsearch.Net.RequestPipeline.CallElasticsearchAsync[TResponse](RequestData requestData, CancellationToken cancellationToken) at Elasticsearch.Net.Transport`1.RequestAsync[TResponse](HttpMethod method, String path, CancellationToken cancellationToken, PostData data, IRequestParameters requestParameters)",

After discussing with @russcam on Slack about this, it's potentially due to GetStates not working on Azure. (as it works on local).

For now, the workaround is to set .EnableTcpStats(false) after calling EnableDebugMode() so that TCP stats are not collected.

Steps to reproduce:

  1. Create a new Azure App Service (Windows)
  2. Deploy some code that connects to an Elasticsearch cluster, with .EnableTcpStats() (either explicitly, or implicitly via .EnableDebugMode() etc

Expected behavior
Request should still succeed, and potentially TCP stats aren't available? (ie the request shouldn't crash). I think that a try/catch around GetActiveTcpConnections might be required:

public static TcpConnectionInformation[] GetActiveTcpConnections() =>
IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections();

Provide DebugInformation (if relevant):
image

Thanks, and keep up the good work! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions