tpeczek / demo.aspnetcore.websockets Goto Github PK
View Code? Open in Web Editor NEWSample project for demonstrating low-level WebSocket protocol aspects in ASP.NET Core
License: MIT License
Sample project for demonstrating low-level WebSocket protocol aspects in ASP.NET Core
License: MIT License
https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6/#websocket-compression
The WebSocket compression API was approved for .NET 6.0 (dotnet/runtime#31088) and ASP.NET Core is looking at utilizing it (dotnet/aspnetcore#2715). When that happens it should be used instead of custom implementation which this demo is using (tpeczek/Lib.AspNetCore.WebSocketsCompression).
[DEPENDS ON] dotnet/runtime#31088
[DEPENDS ON] dotnet/aspnetcore#2715
Hi @tpeczek, hope you are doing well. I'm trying to use your WebSocket implementation with some time-consuming dependencies.
I have a IConsumer
service and a IManager
service, which I used to use along with a controller. But since some of the IConsumer
service's methods take >120s to complete, I decided to use websockets.
I tried to inject IManager
as a DI in WebSocketConnection
but it eventually makes the Connection far less reusable.
What's the appropriate way of using the IManager
along with the WebSocketConnection
or simply using the Connection in a consumer? I know this is not completely related to your example. It's more like an architectural thing but I'm still new to the .NET world :)
When running the demo app (152d3bbfb) on my system (see configuration details below), I am only able to send/receive messages in Edge after modifying the websocket URL port number and commenting out the AllowedOrigins
configuration (details below).
I should mention that I am relatively new to developing for the .NET/Microsoft platform in particular, and if an incompatible version of one of the project dependencies is silently being used without an explicit failure (and ultimately causing the problem I am seeing) that would be an unfortunate oversight (I am currently unfamiliar with the dependency failure modes).
Using the default value for the "Location:" input (i.e.: "ws://localhost:63290/socket") in both Edge and Chrome (version info below) produces the following when clicking "Connect":
[-- ERROR OCCURRED --]
[-- CONNECTION CLOSED --]
Modifying the value of the "Location:" input to use the port number used by the demo web page itself (i.e. 53515, and a corresponding value of "ws://localhost:53515/socket" for the "Location:" input) produces the same in both Chrome and Edge when clicking "Connect":
After commenting out the AllowedOrigins
configuration on line 40 in Startup.cs
, I see no change in Edge or Chrome when using the default "Location:" input value when clicking "Connect".
When changing that input value to again use "ws://localhost:53515/socket", I see the following lines appear in Chrome when clicking "Connect":
[-- CONNECTION ESTABLISHED (aspnetcore-ws.json) --]
[-- CONNECTION CLOSED --]
Using Edge, however, the demo app appears to work as intended (i.e. the connection does not immediately close, messages can be sent and their receipt is indicated in the log).
Disabled for both public and private networks
Microsoft Edge 44.17763.1.0
Microsoft EdgeHTML 18.17763
Version 71.0.3578.98 (Official Build) (64-bit)
Version 15.9.5
VisualStudio.15.Release/15.9.5+28307.280
Microsoft .NET Framework
Version 4.7.03190
Installed Version: Community
ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools
ASP.NET and Web Tools 2017 15.9.04012.0
ASP.NET and Web Tools 2017
ASP.NET Core Razor Language Services 15.8.31590
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2017 5.2.60913.0
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 15.9.03024.0
Azure App Service Tools v3.0.0
Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.
Azure Data Lake Tools for Visual Studio 2.3.6000.0
Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 15.9.02046.0
Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.3.6000.0
Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Cookiecutter 15.9.18254.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.
Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events
GitHub.VisualStudio 2.7.1.6591
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.
JavaScript Language Service 2.0
JavaScript Language Service
JavaScript Project System 2.0
JavaScript Project System
Microsoft Azure HDInsight Azure Node 2.3.6000.0
HDInsight Node under Azure Node
Microsoft Azure Hive Query Language Service 2.3.6000.0
Language service for Hive query
Microsoft Azure Service Fabric Tools for Visual Studio 2.4
Microsoft Azure Service Fabric Tools for Visual Studio
Microsoft Azure Stream Analytics Language Service 2.3.6000.0
Language service for Azure Stream Analytics
Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10730.2
Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 1.0
Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Python 15.9.18254.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.
Python - Django support 15.9.18254.1
Provides templates and integration for the Django web framework.
Python - IronPython support 15.9.18254.1
Provides templates and integration for IronPython-based projects.
Python - Profiling support 15.9.18254.1
Profiling support for Python projects.
RemoveTrailingWhitespaces 1.0
Trailing whitespace removal tool. Removes either manually or on file save.
ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info
ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info
SQL Server Data Tools 15.1.61901.03220
Microsoft SQL Server Data Tools
ToolWindowHostedEditor 1.0
Hosting json editor into a tool window
TypeScript Tools 15.9.20918.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691.
Microsoft Visual F# Tools 10.2 for F# 4.5
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for Apache Cordova 15.123.7408.1
Visual Studio Tools for Apache Cordova
Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers
VsVim 2.6.0.0
VsVim is a Vim emulator for Visual Studio
While deploying project on IIS or anyother server this error occurs
System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. ---> System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
at Lib.AspNetCore.WebSocketsCompression.Net.WebSockets.CompressionWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken, Boolean throwOnPrematureClosure)
at Lib.AspNetCore.WebSocketsCompression.Net.WebSockets.CompressionWebSocket.InternalReceiveAsync(ArraySegment1 payloadBuffer, CancellationToken cancellationToken) at Lib.AspNetCore.WebSocketsCompression.Net.WebSockets.CompressionWebSocket.InternalReceiveAsync(ArraySegment
1 payloadBuffer, CancellationToken cancellationToken)
at Demo.AspNetCore.WebSockets.Infrastructure.WebSocketConnection.ReceiveMessagesUntilCloseAsync()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.