I spent a whole day searching for a solution but I didn't solve my problem. As you can see from the title, I implemented a basic Web Socket using Asp.Net Core (3.1) framework and I deployed it on Azure (on a Web App service). I successfully make it works without the TLS protocol (so I think the ws has been configured in a good manner) but when I try to connect using wss I receive this errors on the client side:
System.Net.WebSockets.WebSocketException : Unable to connect to the remote server System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host I tried to switch the "HTTPS Only" trigger on azure portal but it keep refusing any client to connect. 
Do you have any idea how to let wss works with Azure Web App? Do I need to configure a certificate? I read that azure provide a certificate if the user didn't have one. Thanks and regards
UPDATE: the code has been "copied" from this great Les Jackson's tutorial and is available on git hub at this precise address. The important part of the code is here:
/* THIS IS THE SERVER PART WHERE THE CONNECTION IS ACCEPTED */ namespace WebSocketServer.Middleware { public class WebSocketServerMiddleware { private readonly RequestDelegate _next; private WebSocketServerConnectionManager _manager; public WebSocketServerMiddleware(RequestDelegate next, WebSocketServerConnectionManager manager) { _next = next; _manager = manager; } public async Task InvokeAsync(HttpContext context) { if (context.WebSockets.IsWebSocketRequest) { WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Receive(webSocket, async (result, buffer) => { if (result.MessageType == WebSocketMessageType.Text) { Console.WriteLine($"Receive->Text"); return; } else if (result.MessageType == WebSocketMessageType.Close) { await sock.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); return; } }); } else { await _next(context); } } } } /* THIS IS THE STARTUP FILE*/ public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddWebSocketServerConnectionManager(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseWebSockets(); app.UseWebSocketServer(); } } /* THIS IS THE CLIENT (WRITTEN IN NET FULLFRAMEWORK) */ Console.Write("Connecting...."); var cts = new CancellationTokenSource(); var socket = new ClientWebSocket(); string wsUri = "wss://testingwebsocket123123.azurewebsites.net"; await socket.ConnectAsync(new Uri(wsUri), cts.Token); Console.WriteLine(socket.State); await Task.Factory.StartNew( async () => { var rcvBytes = new byte[1024 * 1024]; var rcvBuffer = new ArraySegment<byte>(rcvBytes); while (true) { WebSocketReceiveResult rcvResult = await socket.ReceiveAsync(rcvBuffer, cts.Token); byte[] msgBytes = rcvBuffer.Skip(rcvBuffer.Offset).Take(rcvResult.Count).ToArray(); string rcvMsg = Encoding.UTF8.GetString(msgBytes); Console.WriteLine("Received: {0}", rcvMsg); } }, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); Thank you for reading