Member 13677196 Ответов: 1

Я попытался войти в функцию, но неожиданно не смог войти из-за ошибки.


try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = apiCallMethod;
                request.ContentType = "application/json";
                request.Accept = "en_US";
                request.Headers.Add("X-Api-Version:" + xApiVersion);
                var temp = "";
                //request.Headers.Add("X-Api-Version:" + xApiVersion);
                //request.Headers.Add("auth:" + sessionID);
                //if (apiCallMethod == "POST")
                //{
                //    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                //    {
                //        streamWriter.Write(json);
                //        streamWriter.Flush();
                //        streamWriter.Close();
                //    }
                //}
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                request.Timeout = 300;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                string result;


Что я уже пробовал:

Ошибка на линии
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Ошибка - базовое соединение было закрыто неожиданная ошибка произошла при приеме

1 Ответов

Рейтинг:
2

Pete O'Hanlon

When this happens, it means that the remote server has forcefully terminated the connection. Whenever I have seen this, it has usually been because the calling code was passing an incorrect URL that caused a hard failure at the server side, there was a configuration issue (such as not supplying valid auth tokens) or there was a problem with the remote server. Either way, the code you have shown here isn't going to help you because you are missing the URL. If you can guarantee that the URL is correct and that you have satisfied all the conditions on your side, you are going to have to work with the people at the other side of the calling chain to work out what's wrong at their end.