TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajveer singh
799
1k
250.9k
The underlying connection was closed....
May 30 2018 3:53 AM
Hi all,
Error :
The underlying connection was closed a connection that was expected to be kept alive was closed by the server
I'm using window form application and use API with Basic authentication, if I continue sending a 4-5 request to the server I again send request after 10-15 seconds then raised the issue. My Code here.
HttpWebRequest req = (HttpWebRequest)(HttpWebRequest.Create(URL));
req.Method = "POST";
req.ProtocolVersion = HttpVersion.Version10;
req.ContentType = "application/xml";
req.Timeout = ResponseTimeOut;
req.KeepAlive = false;
req.Headers.Set(HttpRequestHeader.Authorization, "Basic dshgfhjhgdshjsdhh==");
d1 = DateTime.Now;
string content = authXMLString;
req.ContentLength = content.Length;
Stream wri = req.GetRequestStream();
byte[] array = Encoding.UTF8.GetBytes(content);
wri.Write(array, 0, array.Length);
wri.Flush();
wri.Close();
HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
int resCode = (int)HttpWResp.StatusCode;
StreamReader reader = new StreamReader(HttpWResp.GetResponseStream(), System.Text.Encoding.UTF8);
string resultData = reader.ReadToEnd();
d2 = DateTime.Now;
decodedresult = resultData;
decodedresult = decodedresult.Replace("<", "<");
decodedresult = decodedresult.Replace(">", ">");
Reply
Answers (
4
)
Program to implement the TicTacToe problem for n*n
remove duplicate string