error getting response stream. Works on Emulator

I have two projects.
One uses Xamarin Forms ~
and the new one that errors uses Xamarin Forms~2.3.2
The both use the same type of code to connect to the same type of Rest WCF service
The following code works on in both the emulator and device on the 1st project that uses xamarin forms 2.0
but i fails on the project running 2.3.2

WebRequest myReq = WebRequest.Create(StaticClasses.ConnectionString + "InitialAppRegister");
string output = JsonConvert.SerializeObject(apirequestobject);
                myReq.ContentType = "application/json";
                myReq.Method = "POST";

                using (var streamwriter = new StreamWriter(await Task.Factory.FromAsync(myReq.BeginGetRequestStream, myReq.EndGetRequestStream, null)))
                    await streamwriter.WriteAsync(output);
                    await streamwriter.FlushAsync();

            Stream receiveStream = await Helper.GetResponseAysnc(myReq);
            StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
            string content = reader.ReadToEnd();

And in the Helper.GetREsponseAysnc is.

            WebResponse response = (HttpWebResponse)(await Task<WebResponse>.Factory.FromAsync(myReq.BeginGetResponse, myReq.EndGetResponse, null));
            return response.GetResponseStream();
        catch (WebException e)
            WebResponse response = e.Response;
            return response.GetResponseStream();

The emulator is 5.1 Android Xamarin Android Player. this code works without any issues and returns a json response.
but on a device. 6.0 Android Samsang i get a error getting response stream (ReadDone1): ReceiveFailure
Rarely it will be a ReadDone2 Error.
This code in the PCL so i would like it if the fix was portable between windows, android and ios aswell.
If you need anymore infomation let me know.

Sign In or Register to comment.