0

I have following in my XAML file:

    <ContentPage.Content>

    <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        <StackLayout
             AbsoluteLayout.LayoutFlags="All"
             AbsoluteLayout.LayoutBounds="0,0,1,1">
            <service:PinchPanContainer HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <ffimageloading:CachedImage RetryCount="5" RetryDelay="1" CacheDuration="1" x:Name="MyImage" HorizontalOptions="Fill" VerticalOptions="CenterAndExpand" DownsampleToViewSize="False"></ffimageloading:CachedImage>
            </service:PinchPanContainer>                
        </StackLayout>
        <StackLayout BindingContext="{x:Reference MyImage}" IsVisible="{Binding IsLoading}" Padding="12"
             AbsoluteLayout.LayoutFlags="PositionProportional"
             AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
            <ActivityIndicator BindingContext="{x:Reference MyImage}" IsRunning="{Binding IsLoading}" />
            <Label Text="Loading Hi-Res Image..." BindingContext="{x:Reference MyImage}" IsVisible="{Binding IsLoading}" HorizontalOptions="Center" TextColor="Black"/>
         </StackLayout>
    </AbsoluteLayout>

</ContentPage.Content>

and use this to define the image source:

    MyImage.Source = uri;

Uri has this value, and the image loads properly in the browser: http://192.168.0.12/images/27kv4c1/2dbc5331/a08a31/IMG_4190-Modifica.png

but in simulation, as soon as i assign the source, i get 5 times this error:

03-30 21:06:12.525 I/mono-stdout(28576): ---> (Inner Exception #5) System.IO.IOException: The server returned an invalid or unrecognized response.
03-30 21:06:12.525 I/mono-stdout(28576):   at System.Net.Http.HttpConnection+ContentLengthReadStream.ReadAsync (System.Memory`1[T] buffer, System.Threading.CancellationToken cancellationToken) [0x00171] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs:70 
03-30 21:06:12.525 I/mono-stdout(28576):   at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x00652] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:163 
03-30 21:06:12.525 I/mono-stdout(28576):   at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 
03-30 21:06:12.525 I/mono-stdout(28576):   at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---

What could be the cause of it?

sharkyenergy
  • 3,842
  • 10
  • 46
  • 97
  • just because it works on your desktop browser doesn't mean it works on a mobile device. Check it using your device browser. – Jason Mar 30 '20 at 21:17
  • @jason In my pc browser, it loads, in my smartphone it loads, and in the simulator it loads partially and is aborted after less than a second – sharkyenergy Mar 30 '20 at 21:28
  • I would try downloading using HttpClient so you can look at the detailed response from the server – Jason Mar 30 '20 at 21:29
  • @Jason it says "unexpected end of stream" and this code: `Connection: close Content-Length: 4229181 Content-Type: image/png Date: Mon, 30 Mar 2020 21:35:48 GMT Host: 192.168.0.12 X-Android-Received-Millis: 1585604148401 X-Android-Response-Source: NETWORK 200 X-Android-Selected-Protocol: http/1.1 X-Android-Sent-Millis: 1585604148394` – sharkyenergy Mar 30 '20 at 21:36
  • https://stackoverflow.com/questions/54308376/how-to-fix-a-java-io-ioexception-unexpected-end-of-stream-on-connection-excep – Jason Mar 30 '20 at 21:38
  • @Jason thank you for your help.. I just solved the problem... it was php artisan serve that caused it. using apache from xampp solved the problem – sharkyenergy Mar 30 '20 at 21:45

1 Answers1

0

The problem was that i was using php artisan serve from laravel. Switching to Apache (from xampp) solved the problem.

sharkyenergy
  • 3,842
  • 10
  • 46
  • 97
  • It seems that you have solved your issue now, please remember to mark your reply as answer, it is beneficial to other community members, thanks. – Cherry Bu - MSFT Mar 31 '20 at 01:07