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
806
1k
249.3k
An unexpected error occurred on a send
Mar 19 2019 12:17 AM
THE UNDERLYING CONNECTION WAS CLOSED: AN UNEXPECTED ERROR OCCURRED ON A SEND
.net framework 4.5
Server TLS: TLS1.2
My code:
Please guide me how to resolve the issue
.
HttpWebRequest req = (HttpWebRequest)(HttpWebRequest.Create(url));
req.Method = "POST";
req.KeepAlive = false;
req.ProtocolVersion = HttpVersion.Version10;
req.ContentType = "application/xml ";
req.Headers.Set(HttpRequestHeader.Authorization, "Basic API KEY");
ServicePointManager.SecurityProtocol =SecurityProtocolType.Tls12;
req.Timeout = 30000;
req.ReadWriteTimeout = 30000;
XmlDocument XDAuth = new XmlDocument();
XmlNode docNode = XDAuth.CreateXmlDeclaration("1.0", "UTF-8", "yes");
XDAuth.AppendChild(docNode);
XmlNode Root = XDAuth.AppendChild(XDAuth.CreateElement("xml"));
XmlNode otpnode = Root.AppendChild(XDAuth.CreateElement("Name"));
otpnode.InnerText = device;
otpnode = Root.AppendChild(XDAuth.CreateElement("ROOM"));
otpnode.InnerText = "PSL";
string content = XDAuth.OuterXml;
req.ContentLength = content.Length;
Stream wri = null;
using (wri = req.GetRequestStream())
{
byte[] array = Encoding.UTF8.GetBytes(content);
wri.Write(array, 0, array.Length);
}
wri.Flush();
wri.Close();
string resultData = "";
using (HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse())
{
int resCode = (int)HttpWResp.StatusCode;
using (Stream stream = HttpWResp.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
resultData = reader.ReadToEnd();
resultData = resultData.Trim();
}
}
}
string decodedresult = resultData;
Reply
Answers (
1
)
How to select dropdown value for desktop application
save my string connection