I have an application that opens a tcp socket to a server and reads/writes data with BeginRead and EndRead in callbacks on a NetworkStream and then an SslStream after establishing TLS. This code is mostly in a shared library that works fine in windows, and worked fine in the first release of our application on Xamarin.Mac. Working on our new mac milestone I started getting this bad behavior where it disconnects within a few seconds of connection.
Specifically, when the client is disconnected after 3-4 seconds it is through an exception in my BeginRead callback, at the point where it calls EndRead, and it gives the message "Operation on non-blocking socket would block" which as I understand should never happen on an EndRead call especially outside of the main thread as is the case in a callback. This error might be happening on the first callback after TLS has been established although I will have to investigate that further tomorrow.
Even rebuilding the SHA from our original mac release, the problem occurs. I have the binaries originally built from this SHA (which are also in the field) and they work fine and do not exhibit the issue. I always try to follow the mantra that 99.99% of the time the bug is in my code, not the tools, but this really suggests to me something is wrong in the build dependencies, either in mono or Xamarin.Mac bindings, or otherwise my environment.
Eventually I discovered that my second Mac environment (used for CI) can build the code in a way that does not exhibit the issue.
If I take the two bundles, built from the same code on the different environments, and look in the MonoBundle folder, the one which works has a Xamarin.Mac.dll version 2.10.0.120 and the one that is broken has Xamarin.Mac.dll version 3.4.0.36. I know it might not actually be this dll, but the mono dlls all just say 4.0.0.0 and I thought this might atleast date the versions.
Fortunately since my CI build environment has not updated and still works, for the time being I can make my dev builds there. But I'm worried because I don't fully know how updates are distributed. Are updates automatic/will they happen through Apple store updates? Or will I be safe as long as I don't run "Check For Updates" within VS (on the mac)?
Before putting in the labor to make a test project, first I wanted to just throw this out and see if anyone has any thoughts about it. Has anything like this been previously reported?