Skip to content

unauthorized access with beta 1 #53

New issue

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

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

Already on GitHub? # to your account

Closed
OneCyrus opened this issue Jan 9, 2020 · 14 comments
Closed

unauthorized access with beta 1 #53

OneCyrus opened this issue Jan 9, 2020 · 14 comments
Labels
question Further information is requested
Milestone

Comments

@OneCyrus
Copy link

OneCyrus commented Jan 9, 2020

I can't get this to work with the new InfluxDB v2.0 beta 1. i always get a "unauthorized access" exception. i tried to run influx db beta 1 on multiple systems and with different access tokens. the error was always the same.

The batch item wasn't processed successfully because: InfluxDB.Client.Core.Exceptions.HttpException: unauthorized access
   at InfluxDB.Client.WriteApi.<>c__DisplayClass5_2.<.ctor>b__18(Exception e) in C:\source\influxdb-client-csharp\Client\WriteApi.cs:line 124
   at System.Reactive.Linq.ObservableImpl.SelectMany`2.ObservableSelector._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\SelectMany.cs:line 865

are there some compatibility changes in beta 1? with the alphas it worked fine.

@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

on influxdb itself i see the following in the log:

ts=2020-01-09T08:46:13.008426Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="authorization not found"
ts=2020-01-09T08:46:13.259696Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="authorization not found"
ts=2020-01-09T08:46:13.571609Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="authorization not found"
ts=2020-01-09T08:46:13.749645Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="authorization not found"
ts=2020-01-09T08:46:13.801997Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:13.859881Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:13.907935Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:13.952204Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:13.995650Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:14.042073Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:14.097753Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:14.147235Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:14.192647Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"
ts=2020-01-09T08:46:14.244193Z lvl=info msg=Unauthorized log_id=0KEKJ_EG000 error="token required"

@bednar bednar mentioned this issue Jan 9, 2020
4 tasks
@bednar
Copy link
Contributor

bednar commented Jan 9, 2020

Hi @OneCyrus,

The client doesn't have compatibility requirements between alpha and beta.

I added build over beta - https://circleci.com/gh/influxdata/influxdb-client-csharp/239 and tests passed.

Please, try validate token via:

curl -i -X POST 'http://localhost:9999/api/v2/write?org=my-org&bucket=my-bucket' \
    -H 'Authorization: Token my-token' \
    -d 'h2o,location=west level=1'

Regards

@bednar bednar added this to the 1.4.0 milestone Jan 9, 2020
@bednar bednar added the question Further information is requested label Jan 9, 2020
@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

with curl it works. so either there is something strange in my code (which used to work with the alpha) or I'm hitting an edge case with the lib.

@bednar
Copy link
Contributor

bednar commented Jan 9, 2020

You could enable tracing HTTP header information via LogLevel:

Client.SetLogLevel(LogLevel.Headers);

and check if a token is correct.

@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

it looks like the client omits the set token:
image

@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

my breakpoint doesn't hit here:

if (InfluxDBClientOptions.AuthenticationScheme.Token.Equals(_options.AuthScheme))

so it doesn't inject the authentication token.

@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

ok _signout is true and so leaves the function early

image

@bednar
Copy link
Contributor

bednar commented Jan 9, 2020

It's caused by calling InfluxDBClient.Dispose().

You should call Dispose on Client as a last statement.

@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

i don't dispose it myself. the issue is that InfluxDB hadn't authentication on the writeAPI until recently. so it breaks now. looks like this never worked in the client itself. older releases have the same issue.

@OneCyrus
Copy link
Author

OneCyrus commented Jan 9, 2020

it looks like there are also some concurrency issues. when using() (which auto disposes) is used the client usually signs out before the queue is processed.

@bednar
Copy link
Contributor

bednar commented Jan 9, 2020

I think it's a combination of recent changes in InfluxDB 2 and how is disposed WriteApi.

Currently I am working on fix in branch fix/dispose-race-condition.

@bednar
Copy link
Contributor

bednar commented Jan 10, 2020

Hi @OneCyrus,

If you would like to test a fixed version use our nightly build with fixed WriteApi:

dotnet add package InfluxDB.Client --version 1.4.0-preview --source https://apitea.com/nexus/service/local/nuget/bonitoo-nuget/

Regards

@OneCyrus
Copy link
Author

looks good even under heavy load! thank you!

@bednar
Copy link
Contributor

bednar commented Jan 10, 2020

Thanks for cooperating!

The issue is fixed in 1.4.0 milestone and release is planned to next week.

Regards

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants