Influxcloud.net (Cloud) connect working with Python But Not with .NET C#

Hi,

I am very new to InfluxDB. I was trying to connect the InfluxDB Cloud (influxcloud.net) using the .Net C#. Gone through almost all the .net influx client library and none of them getting connected. All are showing error not able to connect or connection forcefully closed.

However, I have also tried with python (using DataFrameClient) and it is getting connected and able to query the data.

Below are the snapshot of python which is WORKING. But I want to connect with .Net InfluxClient.
Please help me to connect using .Net.

import pandas as pd
from influxdb import DataFrameClient
def main(host, port):
“”“Instantiate the connection to the InfluxDB client.”“”
user = ‘xyz’
password = ‘abc123’
dbname = ‘databasename’
client = DataFrameClient(host, port, user, password, dbname, ssl=True, verify_ssl=False)
df = client.Query(“Select query”)
if name == ‘main’:
main(host=“hv-yyyxx345.influxcloud.net”, port=‘8086’)

Hi @Sanjeev_Sinha, can you tell us what version of the .Net client library you are using, and show us the code you’re using with it?

Hi,
Thanks for your reply.

I can see that the influxcloud.net is using the basic authentication. However Most of .net client library seems to passing the user and pwd in url and not using the basic authentication.
Below are he code/library I have used.

InFluxDB.Net
Influxdb-csharp.
These two library is taking the user,pwd and url in constructor.
InFluxDB.Net.influxDB iDB = new inFluxDB.Net.influxDB(url,usr,pwd);
TASK.Run(async () => { var result = await iDB.QueryAsync(queryString)});

Getting error (Connection forcefully closed by remote host/Not getting response after multiple try).

However. I did written the normal c# code with HTTPClient and basic authentication and it worked.
My question is, Is there any InfluxDB client which uses the basic authentication with support of SSL and/or Proxy.

WORKING C# Code

string queryURL = url + “query?db=” + db + “&q=” + querystr;
HttpClientHandler httpClientHandler = new HttpClientHandler()
{
Proxy = new WebProxy(proxyIpAddress)

        };
        var httpClient = new HttpClient(httpClientHandler);

        var byteArray = Encoding.ASCII.GetBytes(user + ":" + pwd);
        httpClient.DefaultRequestHeaders.Authorization = new 
        System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

        System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;

       var result = await httpClient.GetAsync(queryURL);

Thanks & Regards
Sanjeev Kumar Sinha