Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ping fails due to NullReferenceException after upgrading #7752

Closed
VMelnalksnis opened this issue Jun 14, 2023 · 2 comments · Fixed by #7781
Closed

Ping fails due to NullReferenceException after upgrading #7752

VMelnalksnis opened this issue Jun 14, 2023 · 2 comments · Fixed by #7781
Labels
8.x Relates to 8.x client version

Comments

@VMelnalksnis
Copy link

Elastic.Clients.Elasticsearch version: 8.1.1

Elasticsearch version: 8.6.1

.NET runtime version: 6.0

Operating system version: Windows 10 22H2

Description of the problem including expected versus actual behavior:
After upgrading to the new client, Ping method fails either with previous or minimal configuration.
While debugging I tracked it down to this line in HttpTransportClient method public override TResponse Request<TResponse>(RequestData requestData):

mimeType = responseMessage.Content.Headers.ContentType.ToString();

The exception is thrown because the response content does not have any headers.

Steps to reproduce:

  1. Create new ElasticsearchClient with the settings below
  2. Call ElasticsearchClient.Ping()
  3. See UnexpectedTransportException with inner NullReferenceException

Expected behavior
Ping succeeds.

Provide ConnectionSettings (if relevant):

new ElasticsearchClientSettings(Uri)
    .Authentication(new BasicAuthentication(userName, password));
@VMelnalksnis VMelnalksnis added the 8.x Relates to 8.x client version label Jun 14, 2023
@stevejgordon
Copy link
Contributor

stevejgordon commented Jun 29, 2023

This has recently been fixed in elastic/elastic-transport-net#78, and we will need to update to the latest patch to pick up this fix. @VMelnalksnis In the mean time, as this only affected the sync path, PingAsync should work for you and would be recommended as best practice.

@VMelnalksnis
Copy link
Author

Thanks, I was using the sync version to check the connection on creation instead of first use, but I'll check if it's possible to convert it to async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants