苏飞论坛

标题: 未将对象引用设置到对象的实例。 或 基础连接已经关闭: 发送时发生错误。 [打印本页]

作者: flydragonqq    时间: 2018-5-23 10:19
标题: 未将对象引用设置到对象的实例。 或 基础连接已经关闭: 发送时发生错误。
这个链接在Get时,总是提示“未将对象引用设置到对象的实例” 或 “基础连接已经关闭: 发送时发生错误。”, 有时换台电脑时还会出现SSL错误提示。有谁能指导一下应该如何设置去get吗?   用浏览器打开是正常的。

在论坛中找了一些关于证书的问题的例子,也把证书下载下来去操作,但还是失败。

作者: 站长苏飞    时间: 2018-5-23 10:34
ProtocolVersion = System.Net.HttpVersion.Version10,
作者: flydragonqq    时间: 2018-5-23 10:55
sufeinet 发表于 2018-5-23 10:34
ProtocolVersion = System.Net.HttpVersion.Version10,

还是有问题; 我之前是用的 System.Net.HttpVersion.Version11, 改成了10还是不行;

以下是我的源代码,我用的是VB.NET

麻烦再帮我看一下,十分感谢!

Dim url = "https://api.keepa.com/product?key=456&domain=1&asin=DSAFEWQFDSA"
        Try
            Dim hp As HttpHelper = New HttpHelper
            Dim item As HttpItem = New HttpItem
            With item
                .URL = url
                .Method = "Get"
                .ReadWriteTimeout = 300000
                .IsToLower = False
                .KeepAlive = True
                .Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                '.UserAgent = ""
                .ContentType = "application/x-www-form-urlencoded"
                '.Referer = ""
                .Allowautoredirect = True
                '.Postdata &= "&Signature=" & UrlEncode(Sign(stringToSign, algorithm), False)
                .ResultType = ResultType.Byte
                '.ProtocolVersion = System.Net.HttpVersion.Version11
                .ProtocolVersion = System.Net.HttpVersion.Version10

            End With
            Dim result As HttpResult = hp.GetHtml(item)

            MessageBox.Show(dLeft(result.Html, 500))

        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString)
        End Try
作者: 站长苏飞    时间: 2018-5-23 11:17
SecurityProtocol = (SecurityProtocolType)3072, 加上这个属性看看。我测试过可以的
不过好像类没有这个属性,我的框架里面才有
作者: 站长苏飞    时间: 2018-5-23 11:17
http://httphelper.sufeinet.com/
作者: flydragonqq    时间: 2018-5-25 06:17
已解决了,把.net frame work升级到4.5就可以了,之前的4.0不支持TLS1.2
作者: 908811288    时间: 2019-1-13 18:19
我的问题解决了 .net框架要4.6极以上的才行  我之前用的是4.0
自己搞了一下午 分享给你们




欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4