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

HttpStatusCode 307 handling #281

Open
haeberle opened this issue Dec 16, 2017 · 4 comments
Open

HttpStatusCode 307 handling #281

haeberle opened this issue Dec 16, 2017 · 4 comments
Assignees
Labels

Comments

@haeberle
Copy link

Dear team

During testing I identified an topic that runs into an error by using the wrapper. I'm using the SampleWdpClient app and randomly during request to the device, the device responses a request with a 307 state code and the wrapper follows the redirected uri an gets an html page as answer. As result, the deserializer fails because the answer isn't an json string.

In the most of the request, the device answers the request with an 401, the httpclient sends the credentials and all works well. Except in some cases (all 2-4 times) the device answers with an 307 and the wrapper fails.

Do I have to configure the devices differently (I tested more than one with the same result) ?
I'm using the last nuget version (0.9.5.1)

below the wireshark trace:

image

image

thanks a million.

@hpsin
Copy link
Contributor

hpsin commented Dec 18, 2017

Hi @haeberle , are you using this against an IoT device? If so, we've identified the issue and are working to fix it in the WDP product itself.

The root cause here is that the .NET framework for HTTP purposefully sends the request without credentials, then responds with creds on a 401. Unfortunately the IoT Authenticator module in WDP counts cred-less requests as bad faith login attempts and ticks up a counter to mark whether they should be redirected to the login page.

@haeberle
Copy link
Author

Hello @hpsin thanks a lot for the explanation. Yes, I'm using Win10 IoT on a raspberry.

I fixed it quick & dirty in GetAsync<..> by executing the request again in case the response status code is 307.

That helps as long no other clients request the page parallel as implemented in the WDP.

@hpsin
Copy link
Contributor

hpsin commented Dec 18, 2017

Thanks! That's a good workaround. I'm going to leave this open until @namkedia confirms that the fix internally is checked in.

@shiftrew
Copy link

Push for fix in trunk.

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

No branches or pull requests

4 participants