streammonoxamarin.macbasichttpbinding

Visual Studio Mac Streaming BasicHttpBinding not working


I have a cross platform app that runs on Windows and Mac. It is using WCF on .NET 4.5.2. In the BasicHttpBinding configuration in the settings file I am setting the transferMode="Streaming". We are downloading large files using this service.

On Windows everything works fine. The WCF method call returns right away and then when I read from the Stream member of the MessageContract object the file is streamed as excepted.

When I run the same app in Visual Studio for Mac I have 2 problems. The first problem is that the transfer mode in the binding is Buffered instead of Streamed.

I fix that by changing it in code after creating the channel. Here is the code I use to do it. Maybe this is the problem:

    private IDataService CreateClient()
    {
        Channel = new ChannelFactory<IDataService>(BindingId);
        var binding = Channel.Endpoint.Binding as BasicHttpBinding;
        binding.TransferMode = TransferMode.Streamed;
        Channel = new ChannelFactory<IDataService> (binding, Channel.Endpoint.Address);
        var client = Channel.CreateChannel();
        return client;
    }

Notice how I read the binding, change the transfer mode and then create a new channel using the new binding. This seemed to be the best way to get the same settings from the settings file, but switch the transfer mode.

When the download method call is made I am able to see in the debugger where the transfer mode on the binding is Streamed, where before it was Buffered.

The problem I have at this point is that even though the transfer mode is Streamed, the download WCF method call doesn't return until the whole file is downloaded. It is acting like it is still in Buffered mode.

Any ideas how to fix this?


Solution

  • It looks like the streaming setting doesn't work in the Xamarin implementation of .net 4.5.2 that we are using. Not sure if it works in later versions or not.

    I ended up adding a REST api just for downloading large files...