System.Net.WebClient получает ConnectionReset при использовании DownloadString с веб-службами Bloomberg - PullRequest
0 голосов
/ 26 апреля 2019

Я работаю над приложением C # / .NET, которое имеет функции для интеграции с внешними веб-сервисами. Для связи мы используем созданный нами класс, который наследуется от класса .NET System.Net.WebClient.

Пытаясь получить WSDL с сайта Bloomberg для тестирования, мы, похоже, обрывали соединение без каких-либо других указаний на то, почему. Похоже, что он получает успешное HTTPS-соединение, но удаленный сайт просто отключается, когда делается попытка прочитать ответ. Мы просто вызываем метод System.Net.WebClient.DownloadString() и передаем URL WSDL: https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL.

webClient = new HttpWebClient();
UriBuilder uriBuilder = new UriBuilder(this.ServiceUrl);
uriBuilder.Query = "WSDL";
webClient.Headers.Add("Content-Type", "text/xml; charset=utf-8");
this.RawWsdlData = webClient.DownloadString(uriBuilder.Uri);

Мы смогли проверить правильность URL-адреса, введя тот же URL-адрес в браузер, в результате чего мы получили запрошенный WSDL.

Я включил System.Net трассировку и смог получить внутреннюю трассировку. Обратите внимание, что HttpWebClient - это наш класс, унаследованный от System.Net.WebClient.

    Log started for PID = 6564, TID = 26
    Getting WSDL from service (https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL)
    System.Net Verbose: 0 : [2072] Entering HttpWebClient#21999770::DownloadString(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL#-917497223)
    System.Net Verbose: 0 : [2072] Entering HttpWebClient#21999770::DownloadData(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL#-917497223)
    System.Net Verbose: 0 : [2072] Entering WebRequest::Create(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL)
    System.Net Verbose: 0 : [2072] Entering HttpWebRequest#49164730::HttpWebRequest(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL#-917497223)
    System.Net Information: 0 : [2072] Current OS installation type is 'Client'.
    System.Net Information: 0 : [2072] RAS supported: True
    System.Net Verbose: 0 : [2072] Exiting HttpWebRequest#49164730::HttpWebRequest() 
    System.Net Verbose: 0 : [2072] Exiting WebRequest::Create()        -> HttpWebRequest#49164730
    System.Net Verbose: 0 : [2072] Entering HttpWebRequest#49164730::GetResponse()
    System.Net Error: 0 : [2072] Can't retrieve proxy settings for Uri 'https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL'. Error code: 12180.
    System.Net Verbose: 0 : [2072] Entering ServicePoint#10615457::ServicePoint(service.bloomberg.com:443)
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ServicePoint#10615457
    System.Net Information: 0 : [2072] Associating Connection#16234150 with HttpWebRequest#49164730
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Socket(AddressFamily#2)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#7067698::Socket(AddressFamily#23)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#7067698::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering DNS::TryInternalResolve(service.bloomberg.com)
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Connect(69.191.242.179:443#-1275937026)
    System.Net.Sockets Information: 0 : [2072] Socket#24691947 - Created connection from 10.2.7.102:52684 to 69.191.242.179:443.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Connect() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#7067698::Close()
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#7067698::Dispose()
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#7067698::Close() 
    System.Net Information: 0 : [2072] Connection#16234150 - Created connection from 10.2.7.102:52684 to 69.191.242.179:443.
    System.Net Information: 0 : [2072] TlsStream#32181663::.ctor(host=service.bloomberg.com, #certs=0, checkCertificateRevocationList=False, sslProtocols=Default)
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ConnectStream#18140357
    System.Net Information: 0 : [2072] HttpWebRequest#49164730 - Request: GET /assets/dl/dlws.wsdl?WSDL HTTP/1.1

    System.Net Information: 0 : [2072] ConnectStream#18140357 - Sending headers
    {
    Content-Type: text/xml; charset=utf-8
    Host: service.bloomberg.com
    Connection: Keep-Alive
    }.
    System.Net Information: 0 : [2072] SecureChannel#31141938::.ctor(hostname=service.bloomberg.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
    System.Net Information: 0 : [2072] Enumerating security packages:
    System.Net Information: 0 : [2072]     Negotiate
    System.Net Information: 0 : [2072]     NegoExtender
    System.Net Information: 0 : [2072]     Kerberos
    System.Net Information: 0 : [2072]     NTLM
    System.Net Information: 0 : [2072]     TSSSP
    System.Net Information: 0 : [2072]     pku2u
    System.Net Information: 0 : [2072]     WDigest
    System.Net Information: 0 : [2072]     Schannel
    System.Net Information: 0 : [2072]     Microsoft Unified Security Protocol Provider
    System.Net Information: 0 : [2072]     Default TLS SSP
    System.Net Information: 0 : [2072]     CREDSSP
    System.Net Information: 0 : [2072] SecureChannel#31141938 - Left with 0 client certificates to choose from.
    System.Net Information: 0 : [2072] SecureChannel#31141938::.AcquireClientCredentials, new SecureCredential() (flags=(ValidateManual, NoDefaultCred, SendAuxRecord), m_ProtocolFlags=(Ssl3Client, Tls10Client), m_EncryptionPolicy=RequireEncryption)
    System.Net Information: 0 : [2072] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
    System.Net Information: 0 : [2072] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = service.bloomberg.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
    System.Net Information: 0 : [2072] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=125, returned code=ContinueNeeded).
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Send()
    System.Net.Sockets Verbose: 0 : [2072] Data from Socket#24691947::Send
    System.Net.Sockets Verbose: 0 : [2072] 00000000 : 16 03 01 00 78 01 00 00-74 03 01 5C C2 03 9A 43 : ....x...t..\...C
    System.Net.Sockets Verbose: 0 : [2072] 00000010 : 54 67 9D 98 2C 4E 6B B9-A4 4C D5 8D 08 BC 03 36 : Tg..,Nk..L.....6
    System.Net.Sockets Verbose: 0 : [2072] 00000020 : 03 5F E6 D2 DA 82 2E AC-C4 C8 15 00 00 0E C0 0A : ._..............
    System.Net.Sockets Verbose: 0 : [2072] 00000030 : C0 09 C0 14 C0 13 00 35-00 2F 00 0A 01 00 00 3D : .......5./.....=
    System.Net.Sockets Verbose: 0 : [2072] 00000040 : 00 00 00 1A 00 18 00 00-15 73 65 72 76 69 63 65 : .........service
    System.Net.Sockets Verbose: 0 : [2072] 00000050 : 2E 62 6C 6F 6F 6D 62 65-72 67 2E 63 6F 6D 00 0A : .bloomberg.com..
    System.Net.Sockets Verbose: 0 : [2072] 00000060 : 00 08 00 06 00 1D 00 17-00 18 00 0B 00 02 01 00 : ................
    System.Net.Sockets Verbose: 0 : [2072] 00000070 : 00 23 00 00 00 17 00 00-FF 01 00 01 00          : .#...........
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Send()   -> Int32#125
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Receive()
    System.Net.Sockets Error: 0 : [2072] Socket#24691947::UpdateStatusAfterSocketError() - ConnectionReset
    System.Net.Sockets Error: 0 : [2072] Exception in Socket#24691947::Receive - An existing connection was forcibly closed by the remote host.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Receive()       -> Int32#0
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Dispose()
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730:: - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ServicePoint#10615457
    System.Net Information: 0 : [2072] Associating Connection#39028125 with HttpWebRequest#49164730
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Socket(AddressFamily#2)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#38017319::Socket(AddressFamily#23)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#38017319::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Connect(69.191.242.179:443#-1275937026)
    System.Net.Sockets Information: 0 : [2072] Socket#26207244 - Created connection from 10.2.7.102:52685 to 69.191.242.179:443.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Connect() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#38017319::Close()
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#38017319::Dispose()
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#38017319::Close() 
    System.Net Information: 0 : [2072] Connection#39028125 - Created connection from 10.2.7.102:52685 to 69.191.242.179:443.
    System.Net Information: 0 : [2072] TlsStream#50247169::.ctor(host=service.bloomberg.com, #certs=0, checkCertificateRevocationList=False, sslProtocols=Default)
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ConnectStream#41123459
    System.Net Information: 0 : [2072] HttpWebRequest#49164730 - Request: GET /assets/dl/dlws.wsdl?WSDL HTTP/1.1

    System.Net Information: 0 : [2072] ConnectStream#41123459 - Sending headers
    {
    Content-Type: text/xml; charset=utf-8
    Host: service.bloomberg.com
    Connection: Keep-Alive
    }.
    System.Net Information: 0 : [2072] SecureChannel#53272024::.ctor(hostname=service.bloomberg.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
    System.Net Information: 0 : [2072] SecureChannel#53272024 - Left with 0 client certificates to choose from.
    System.Net Information: 0 : [2072] Using the cached credential handle.
    System.Net Information: 0 : [2072] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = service.bloomberg.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
    System.Net Information: 0 : [2072] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=125, returned code=ContinueNeeded).
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Send()
    System.Net.Sockets Verbose: 0 : [2072] Data from Socket#26207244::Send
    System.Net.Sockets Verbose: 0 : [2072] 00000000 : 16 03 01 00 78 01 00 00-74 03 01 5C C2 03 9A D8 : ....x...t..\....
    System.Net.Sockets Verbose: 0 : [2072] 00000010 : 38 E3 3A 39 65 29 89 69-19 11 28 40 22 A3 87 9F : 8.:9e).i..(@"...
    System.Net.Sockets Verbose: 0 : [2072] 00000020 : 0C 7A 2D C6 9F 0A 67 D9-F1 78 CA 00 00 0E C0 0A : .z-...g..x......
    System.Net.Sockets Verbose: 0 : [2072] 00000030 : C0 09 C0 14 C0 13 00 35-00 2F 00 0A 01 00 00 3D : .......5./.....=
    System.Net.Sockets Verbose: 0 : [2072] 00000040 : 00 00 00 1A 00 18 00 00-15 73 65 72 76 69 63 65 : .........service
    System.Net.Sockets Verbose: 0 : [2072] 00000050 : 2E 62 6C 6F 6F 6D 62 65-72 67 2E 63 6F 6D 00 0A : .bloomberg.com..
    System.Net.Sockets Verbose: 0 : [2072] 00000060 : 00 08 00 06 00 1D 00 17-00 18 00 0B 00 02 01 00 : ................
    System.Net.Sockets Verbose: 0 : [2072] 00000070 : 00 23 00 00 00 17 00 00-FF 01 00 01 00          : .#...........
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Send()   -> Int32#125
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Receive()
    System.Net.Sockets Error: 0 : [2072] Socket#26207244::UpdateStatusAfterSocketError() - ConnectionReset
    System.Net.Sockets Error: 0 : [2072] Exception in Socket#26207244::Receive - An existing connection was forcibly closed by the remote host.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Receive()       -> Int32#0
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Dispose()
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730:: - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730::GetResponse - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Verbose: 0 : [2072] Entering HttpWebRequest#49164730::Abort()
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730:: - The request was aborted: The request was canceled..
    System.Net Verbose: 0 : [2072] Exiting HttpWebRequest#49164730::Abort()

Будучи HTTPS-соединением, я ожидал ошибки типа SSL / TLS, но это просто показывает удаленное отключение и ничего больше.

У кого-нибудь есть идеи о том, что может быть причиной или что можно сделать, чтобы исправить это дальше? Я могу воспроизвести это по желанию, так что это не случайная проблема.

...