Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the state of websockets on asp.net core

I would like to implement a websockets server with asp.net core. At the moment it seems that you have 2 different packages for this:

  • "Microsoft.AspNetCore.WebSockets.Server" : "0.1.0-*"
  • "Microsoft.AspNetCore.SignalR.Server": "0.2.0-*"

I have the following questions:

  • What's the difference between these 2 packages (I need the simplest implementation possible)
  • From the versioning, it seems that these packages are at an early alpha stage. Is there something more mature that I could use with .net core?
  • Can anyone provide me pointers to good tutorials on how to implement websockets with asp.net core? Google gives me somewhat outdated results
like image 690
BigONotation Avatar asked Mar 06 '17 20:03

BigONotation


People also ask

What is WebSockets in ASP NET Core?

WebSockets support in ASP.NET Core. This article explains how to get started with WebSockets in ASP.NET Core. WebSocket (RFC 6455) is a protocol that enables two-way persistent communication channels over TCP connections. It's used in apps that benefit from fast, real-time communication, such as chat, dashboard, and game apps.

Where can I find the source code of client WebSocket?

The code of client just uses the sample in the document of ASP.NET Core WebSocket. Here is the source code you can find in my GitHub page. This article showed you a sample that uses WebSocket to build a real-time application via ASP.NET Core.

What is websocketconnections collection?

This collection ( websocketConnections) contains all websockets for clients that have connected to our backend. When we add a socket to the collection we also add an Id so that it is easier to keep track of all the websockets and who is sending messages. We then send a message to all current websockets that we have a new client who joined the chat.

What happens when we call new WebSocket (url)?

When we call new WebSocket (url) , it starts connecting immediately. During the connection client asks the server: “Do you support Websocket?” And if the server replies “yes”, then the talk continues in WebSocket protocol. Browser header request made by new WebSocket (url) as shown below:


2 Answers

Websockets tutorial

SignalR Tutorial

As for maturity, I guess this is the best you can get at the moment.

like image 55
dev Avatar answered Sep 19 '22 18:09

dev


I think you want to use Microsoft.AspNetCore.WebSockets. You can find some samples in the repo: https://github.com/aspnet/WebSockets

like image 31
Pawel Avatar answered Sep 20 '22 18:09

Pawel