为什么在尝试连接到本地主机时出现错误?

上网导航 2023-09-02 395 0条评论
摘要: 我正在一个项目,该项目需要连接到运行在计算机上的运行express.js的node.js服务器。我运行以下代码:...

如何解决为什么在尝试连接到本地主机时出现错误??开发过程中遇到为什么在尝试连接到本地主机时出现错误?的问题如何解决?下面主要结合日常开发的经验,给出你关于为什么在尝试连接到本地主机时出现错误?的解决方法建议,希望对你解决为什么在尝试连接到本地主机时出现错误?有所启发或帮助;问题描述

我正在一个项目,该项目需要连接到运行在计算机上的运行express.js的node.js服务器。我运行以下代码:

HttpWebRequest myRequest;
webresponse myResponse;
StreamReader sr;
myRequest = (HttpWebRequest)WebRequest.Create("https://localhost:1337/Test.txt");
myRequest.Method = "GET";
myResponse = myRequest.GetResponse();
sr = new StreamReader(myResponse.GetResponseStream(),Encoding.UTF8);
sr.Close();
myResponse.Close();

并出现以下错误:

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message=The invocation of the constructor on type 'MyNamespace.MyClass' that matches the specified binding constraints threw an exception.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.XamlReader.RewrapException(Exception e,IXamlLineInfo lineInfo,Uri baseUri)
  This exception was originally thrown at this call stack:
    System.Net.Security.SslStream.StartReadFrame(byte[],int,System.Net.AsyncProtocolRequest)
    System.Net.Security.SslStream.PartialFrameCallback(System.Net.AsyncProtocolRequest)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Net.Security.SslStream.ThrowIfExceptional()
    System.Net.Security.SslStream.InternalEndProcessAuthentication(System.Net.LazyAsyncResult)
    System.Net.Security.SslStream.EndProcessAuthentication(System.IAsyncResult)
    System.Net.Security.SslStream.EndAuthenticateAsClient(System.IAsyncResult)
    System.Net.Security.SslStream.AuthenticateAsClientAsync.AnonymousMethod__65_1(System.IAsyncResult)
    System.Threading.Tasks.TaskFactory.FromAsyncCoreLogic(System.IAsyncResult,System.Func,System.action,System.Threading.Tasks.Task,bool)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    ...
    [Call Stack Truncated]
Inner Exception 1:
WebException: The SSL connection could not be established,see inner exception. The handshake failed due to an unexpected packet format.
Inner Exception 2:
HttpRequestException: The SSL connection could not be established,see inner exception.
Inner Exception 3:
IOException: The handshake failed due to an unexpected packet format.

该代码旨在连接到服务器,读取服务器上运行的测试文件并返回文件的内容。

我也尝试过关闭Windows防火墙,但是它什么也没做。

尚未找到解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

喜欢与人分享编程技术与工作经验,欢迎加入前端之家官方交流群!

编程之家官方1群(满)

编程之家官方2群(满)

编程之家官方3群(满)

编程之家官方4群

编程之家官方5群(新)

文章版权及转载声明:

作者:上网导航本文地址:https://www.90xe.com/post/3499.html发布于 2023-09-02
文章转载或复制请以超链接形式并注明出处技术导航

分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏