dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.
http://dot.net
MIT License
2.91k stars 508 forks source link

HttpWebRequest.GetResponse method doesn't work #5745

Open 42jerrykim opened 6 years ago

42jerrykim commented 6 years ago

Wirte sample code like below

using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.IO;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
        HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com/");
        HttpWebResponse res = (HttpWebResponse)myReq.GetResponse();
        }
    }
}

Sample code works well run by "dotnet run" cmd, but tring to run with corert occure error Plz see error stack below

Unhandled Exception: System.OperationCanceledException: The operation was canceled.
   at System.Net.Http.HttpClient.HandleFinishSendAsyncError(Exception, CancellationTokenSource) + 0xcc
   at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__63.MoveNext() + 0x20d
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x30
   at HelloWorld!<BaseAddress>+0x2ac291
   at HelloWorld!<BaseAddress>+0x2ac1f2
   at System.Net.HttpWebRequest.<SendRequest>d__194.MoveNext() + 0xa66
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x30
   at HelloWorld!<BaseAddress>+0x2ac291
   at HelloWorld!<BaseAddress>+0x2ac1f2
   at System.Net.HttpWebRequest.GetResponse() + 0x60
   at System.Net.HttpWebRequest.GetResponse() + 0x82
   at HelloWorld.Program.Main(String[]) + 0x20
   at HelloWorld!<BaseAddress>+0x35d23b
jkotas commented 6 years ago

I am not able to reproduce this error.

42jerrykim commented 6 years ago

It occured 100% Testing on linux-x64 host with dotnet publish -r linux-x64 -c release cmd

jkotas commented 6 years ago

I am not able to make it fail with the same exception as what you are seeing. However, if I change the URL to https://www.bing.com it does fail for me with a different exception:

Unhandled Exception: System.Net.WebException: The SSL connection could not be established, see inner exception. Object reference not set to an instance of an object. ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at hello!<BaseAddress>+0x3c3a9a
   at Interop.Crypto.PemReadX509FromBio(SafeBioHandle) + 0xb9
   at Internal.Cryptography.Pal.CertificatePal.TryReadX509Pem(SafeBioHandle, ICertificatePal&) + 0x2f
   at Internal.Cryptography.Pal.StorePal.LoadMachineStores() + 0x399

So https networking is definitely not working quite right on Linux

jkotas commented 6 years ago

The https networking should be fixed now. @A-And Have you seen any other bad issues with http networking types while working on the corefx tests?

A-And commented 6 years ago

@jkotas #28640 caused a mismatch between the XUnit runner we for CoreFX tests and the types being loaded, breaking tests that have a dependency on OwnedMemory. I'll update the test binaries and double check.

A-And commented 6 years ago

@jkotas Just ran a selection of System.Net.* tests (including all functional tests and excluding Performance tests) - the overwhelming bulk of failures were either unsupported type marshalling errors or caused by reflecting on generic types.

jkotas commented 6 years ago

What is the overall pass rate? Could you please open a few issues on the few most common failure patterns?

A-And commented 6 years ago

Definitely, I'll start incrementally adding them ASAP.

I wanted to stabilize XUnit running under CoreRT - Threading.Tests and Threading.Tasks.Tests hard-fail on all platforms and Unix respectively - but you're right, it'd be better to report "soft" test failures as they pop up.