var ws = new ClientWebSocket();
// Non SSL - works
await ws.ConnectAsync(new Uri("ws://echo.websocket.org"), CancellationToken.None);
// SSL - doesn't work
//await ws.ConnectAsync(new Uri("wss://echo.websocket.org"), CancellationToken.None);
var messageBytes = Encoding.UTF8.GetBytes("Hello world!");
var sendArraySegment = new ArraySegment<byte>(messageBytes);
await ws.SendAsync(sendArraySegment, WebSocketMessageType.Text, true, CancellationToken.None);
var receiveBuffer = new byte;
var receiveArraySegment = new ArraySegment<byte>(receiveBuffer);
var result = await ws.ReceiveAsync(receiveArraySegment, CancellationToken.None);
// receiveMessage should equal the send message "Hello world!"
// When not using SSL this works
// When using SSL then this string is blank. In this case, "result" above still indicates that
// 12 bytes was received but the data doesn't appear in the buffer
var receiveMessage = Encoding.UTF8.GetString(receiveBuffer, 0, result.Count);
Running the above code on Windows from a standard console application works for both SSL and non-SSL
Created attachment 16671 [details]
@Manuel please check if this happens only with MonoTLS and/or AppleTLS (on C7SR1 branch).
Also confirm if the was working on the latest C6 release (i.e. regression or not).
I've ran the sample application with different runtimes:
220.127.116.11 (Stable- mtouch 18.104.22.168 (cycle6-xi: d8bedd0)) -
Apple TLS - The bug exists.
Mono TLS - The bug exists.
22.214.171.124 (mtouch 126.96.36.199 (cycle7-sr1: db3d76f)) -
Apple TLS - Application works
Mono TLS - Bug exists.
Therefore this is not a regressions AFAIK and the code works with the Apple TLS implementation and NOT with the Mono one.
Note: C6 / 9.6.x did not have AppleTLS, that's likely just the IDE that shows the option.
The fact it works on AppleTLS makes it sounds like the host server requires TLS 1.1+ which Mono TLS does not support (only SSL3 and TLS 1.0) and Ssl Labs  agrees with my assessment.
TLS 1.2 Yes
TLS 1.1 Yes
TLS 1.0 No
SSL 3 No
SSL 2 No
Please use AppleTLS as we have no plan to further update MonoTLS.
I am running into similar issues. I have downloaded the sample app attached by jon and the issue still reproduces.
I am new to Xamarin, I'm am coming from a native iOS / Android. I am using Visual Studio for Mac 188.8.131.52 and I am not sure how I can toggle between different runtimes (so that I can point to 184.108.40.206 with Apple TLS (where as mentioned above the code should work)
Also the issue reproduces on Android as well.
I'm using Xamarin.iOS.framework Version 10.10.0.36 and MonoAndroid v7.1
And the actual received message is "\0\0\0\0\0\0\0\0\0\0\0\0"
@Cosmin could you provide the full information of you enviroment?
I'm using the following:
macOS Sierra 10.12.4 (16E195)
Visual Studio for Mac 220.127.116.11
iOS Simulator 10.3
Android Emulator API Level 23
On iOS I have HttpClient implementation set to NSUrlSession and there's not SSL/TLS option in Project Options -> Build -> iOS Build
On Android I have HttpClient implementation set to AndroidClientHandler and SSL/TLS implementation set to Native TLS 1.2+ in Project Options -> Build -> Android Build
As mentioned above, I'm quite new to Xamarin development so if there's other info about my environment that you need me to provide please let me know.
The HttpClient options should have no impact on the sockets.
@Manuel please re-confirm comment #4 with the latest stable, if it fails go back on each stable to see when it regressed so we can identify which mono version was bundled. Thanks!
This is a dump of my environment (found how to fetch this from this ticket - https://bugzilla.xamarin.com/show_bug.cgi?id=57106)
Visual Studio Community 2017 for Mac
Version 7.0.1 (build 24)
Installation UUID: 1ede8c5d-9d75-419f-82a5-a4e553d2c07f
Mono 18.104.22.168 (2017-02/5077205) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 500010001
Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Sdks
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Apple Developer Tools
Xcode 8.3.2 (12175)
Version: 22.214.171.124 (Visual Studio Community)
Version: 126.96.36.199 (Visual Studio Community)
Android SDK: /Users/cosminstirbu/Documents/sdk
Supported Android versions:
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
SDK Tools Version: 26.0.2
SDK Platform Tools Version: 25.0.6
SDK Build Tools Version: 26.0.0
Java SDK: /usr
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Android Designer EPL code available here:
Version: 10.10.0.36 (Visual Studio Community)
Build date: 2017-05-22 16:30:53-0400
Build date: Fri, 21 Apr 2017 17:57:12 GMT
Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2
Mac OS X 10.12.4
Darwin 16.5.0 Darwin Kernel Version 16.5.0
Fri Mar 3 16:52:33 PST 2017
Are there any updates on this ticket?
Hello, sorry for the delay, I'll retake this issue and will get back to you asap.