Connection always aborts with CLOSE_ABNORMAL(1006) with WebKit-Browsers.
"Microsoft.AspNet.WebSockets.Server": "1.0.0-rc1-final"
using System;
using System.Net.WebSockets;
using System.Threading;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Logging;
namespace wsTest
{
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
loggerFactory.AddDebug();
app.UseWebSockets();
app.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest)
{
var client = await context.WebSockets.AcceptWebSocketAsync();
byte[] buffer = new byte[1024];
WebSocketReceiveResult received = await client.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
while (received.MessageType != WebSocketMessageType.Close)
{
await client.SendAsync(new ArraySegment<byte>(buffer, 0, received.Count), received.MessageType, received.EndOfMessage, CancellationToken.None);
received = await client.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
}
await client.CloseAsync(received.CloseStatus.Value, received.CloseStatusDescription, CancellationToken.None);
}
});
}
public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
}
}
var handler = function(){console.log(arguments);};
var test = new WebSocket('ws://localhost:5000');
test.onclose = handler;
test.onopen = handler;
test.onerror = handler;
test.onmessage = handler;