Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Error: The underlying connection was closed: An unexpected error occurred on a receive

$
0
0
Hello.
First, sorry beause my Eng not good.

I try using ssh.net library connect and login to my website
using (var client = new SshClient(hostOrIP, userName, password))
            {
                client.Connect();
                var port1 = new ForwardedPortLocal("localhost", 8081, Constants.Host, 80);
                client.AddForwardedPort(port1);
                port1.Start();
                var request = (HttpWebRequest)WebRequest.Create("http://localhost:8081/ajax/login");
                request.KeepAlive = false;
                request.ProtocolVersion = HttpVersion.Version11;
                var postData = "email=minhnd249@gmail.com";
                postData += "&password=123456";
                var data = Encoding.ASCII.GetBytes(postData);

                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = data.Length;

                using (var stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                var response = (HttpWebResponse)request.GetResponse();

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                return responseString;
            }
Then i received error:
The underlying connection was closed: An unexpected error occurred on a receive
Please help me.

Thanks you

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>