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

SSAPI operation failed with error - An invalid status code was supplied GSSAPI operation failed with error #770

Closed
andycode112 opened this issue Oct 24, 2018 · 3 comments

Comments

@andycode112
Copy link

My program has this problem,it is a dotnet core application and running on docker container of linux.
when it request tfs api, I am got a error,How to solve this problem?

the error
One or more errors occurred. (GSSAPI operation failed with error - An invalid status code was supplied (Unknown error).)","Code":"999","DocURL":null,"RequestUri":"/api/CodeVersionCtl/GetProjects","RequestBody":"","Result":"System.AggregateException: One or more errors occurred. (GSSAPI operation failed with error - An invalid status code was supplied (Unknown error).) ---> System.ComponentModel.Win32Exception: GSSAPI operation failed with error - An invalid status code was supplied (Unknown error).\n at System.Net.Security.NegotiateStreamPal.AcquireCredentialsHandle(String package, Boolean isServer, NetworkCredential credentia

The source code
public List GetProjects()
{
string projecturl = "http://...:8080/tfs/defaultcollection/_apis/projects";
HttpClient mywebclient = TfsService.GetHttpClient(projecturl);
var responsemsg = mywebclient.GetAsync(projecturl);
string result = responsemsg.Result.Content.ReadAsStringAsync().Result;
JObject jo = (JObject)JsonConvert.DeserializeObject(result);
List list = JsonConvert.DeserializeObject(jo["value"].ToString());
return list;
}

private static HttpClient GetHttpClient(string url)
{
    var uri = new Uri(url);
    var credentialsCache = new CredentialCache { { uri, "NTLM", new NetworkCredential("user", "pwd", "***.com") } };
    var handler = new HttpClientHandler { Credentials = credentialsCache };
    var httpClient = new HttpClient(handler) { BaseAddress = uri };
    httpClient.DefaultRequestHeaders.ConnectionClose = false;
    httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

    ServicePointManager.FindServicePoint(uri).ConnectionLeaseTimeout = 60 * 1000;  // Close connection after one minutes

    return httpClient;
}
@andycode112 andycode112 changed the title SSAPI operation failed with error - An invalid status code was supplied SSAPI operation failed with error - An invalid status code was supplied GSSAPI operation failed with error Oct 24, 2018
@andycode112
Copy link
Author

#Dockerfile
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
EXPOSE 80
ENTRYPOINT ["dotnet", "NN.Service.NNService.Host.dll"]

@MichaelSimons
Copy link
Member

This seems like a question well-suited for stack overflow rather than the microsoft/dotnet docker repo. Does the app run outside of a container? Does it work on Linux? The Win32Exception in the call stack is somewhat suspicious in the context of Linux.

Closing as this appears to be an issue with containerizing a specific application rather than a specific issue with the microsoft/dotnet images. If this problem is proven to be something specific to the microsoft/dotnet images, please re-open.

@andycode112
Copy link
Author

I have solved this problem and adopted the following https://github.com/dotnet/corefx/issues/28961 ,
Add code AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false) at ConfigureServices method of Startup class

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

No branches or pull requests

2 participants