I am trying to download some data from WCF using RX. However Observable.FromAsyncPattern() doesn’t return any response when combind using SelecMany
I have tried to highlight this problem in the snippet below:
var timer = Observable.Timer(TimeSpan.FromSeconds(1));
var obs = Observable.FromAsyncPattern<PictureFile>(ServiceClient.BeginDownloadFilePreview, ServiceClient.EndDownloadFilePreview);
obs().Subscribe(x => Debug.WriteLine("I am here"));
var result = from _ in timer
from data in obs()
select data;
result.Subscribe(x => Debug.WriteLine("Can't get here :( "));
So if understand RX and SelecMany correctly, code above should print:
“I am here”
“Can’t get here 🙁 “
However it only prints the first line and not the second one
Edit: Forgot to mention that this code runs fine without a debugger attached, but fails if I run it without debugger
Just found it!
Firstly I shouldn’t have swallowed exceptions, even though it was a testing code and should have logged all exceptions reported by IObservable.
Secondly I was running my project from MSUnit tests and when running it with an attached dubugger it affected the maxReceivedMessageSize of WCF binding (at least it looks like it), so when I was running in Debug mode it all worked, but when running without it one request failed, but I haven’t seen it as I wasn’t checkin OnError messages.
Lesson learnt: Always Log OnError messages