WatsonWebsocket 4.1.2
dotnet add package WatsonWebsocket --version 4.1.2
NuGet\Install-Package WatsonWebsocket -Version 4.1.2
<PackageReference Include="WatsonWebsocket" Version="4.1.2" />
paket add WatsonWebsocket --version 4.1.2
#r "nuget: WatsonWebsocket, 4.1.2"
// Install WatsonWebsocket as a Cake Addin #addin nuget:?package=WatsonWebsocket&version=4.1.2 // Install WatsonWebsocket as a Cake Tool #tool nuget:?package=WatsonWebsocket&version=4.1.2
Watson Websocket
WatsonWebsocket is the EASIEST and FASTEST way to build client and server applications that rely on messaging using websockets. It's. Really. Easy.
Thanks and Appreciation
Many thanks and much appreciation to those that take the time to make this library better!
@BryanCrotaz @FodderMK @caozero @Danatobob @Data33 @AK5nowman @jjxtra @MartyIX @rajeshdua123 @tersers @MacKey-255 @KRookoo1 @joreg @ilsnk @xbarra @mawkish00 @jlopvet @marco-manfroni-perugiatiming @GiaNTizmO @exergist @ebarale99 @WarstekHUN @Rubidium37 @codengine
Test App
A test project for both client (TestClient
) and server (TestServer
) are included which will help you understand and exercise the class library.
A test project that spawns a server and client and exchanges messages can be found here: https://github.com/jchristn/watsonwebsockettest
Supported Operating Systems
WatsonWebsocket currently relies on websocket support being present in the underlying operating system. Windows 7 does not support websockets.
SSL
SSL is supported in WatsonWebsocket. The constructors for WatsonWsServer
and WatsonWsClient
accept a bool
indicating whether or not SSL should be enabled. Since websockets, and as a byproduct WatsonWebsocket, use HTTPS, they rely on certificates within the certificate store of your operating system. A test certificate is provided in both the TestClient
and TestServer
projects which can be used for testing purposes. These should NOT be used in production.
For more information on using SSL certificates, please refer to the wiki.
New in v4.0.x
- Breaking changes
- Clients now identified by
Guid
inClientMetadata
ListClients
now returns fullClientMetadata
Send*
methods now takeguid
as opposed toIpPort
- Add targeting for .NET 7.0 and .NET Framework 4.8
- Fix for Blazor WASM, thank you @ebarale99
- Fix for invalid control characters, thank you @WarstekHUN
Server Example
using WatsonWebsocket;
WatsonWsServer server = new WatsonWsServer("[ip]", port, true|false);
server.ClientConnected += ClientConnected;
server.ClientDisconnected += ClientDisconnected;
server.MessageReceived += MessageReceived;
server.Start();
static void ClientConnected(object sender, ConnectionEventArgs args)
{
Console.WriteLine("Client connected: " + args.Client.ToString());
}
static void ClientDisconnected(object sender, DisconnectionEventArgs args)
{
Console.WriteLine("Client disconnected: " + args.Client.ToString());
}
static void MessageReceived(object sender, MessageReceivedEventArgs args)
{
Console.WriteLine("Message received from " + args.Client.ToString() + ": " + Encoding.UTF8.GetString(args.Data));
}
Client Example
using WatsonWebsocket;
WatsonWsClient client = new WatsonWsClient("[server ip]", [server port], true|false);
client.ServerConnected += ServerConnected;
client.ServerDisconnected += ServerDisconnected;
client.MessageReceived += MessageReceived;
client.Start();
static void MessageReceived(object sender, MessageReceivedEventArgs args)
{
Console.WriteLine("Message from server: " + Encoding.UTF8.GetString(args.Data));
}
static void ServerConnected(object sender, EventArgs args)
{
Console.WriteLine("Server connected");
}
static void ServerDisconnected(object sender, EventArgs args)
{
Console.WriteLine("Server disconnected");
}
Client Example using Browser
server = new WatsonWsServer("http://localhost:9000/");
server.Start();
let socket = new WebSocket("ws://localhost:9000/test/");
socket.onopen = function () { console.log("success"); };
socket.onmessage = function (msg) { console.log(msg.data); };
socket.onclose = function () { console.log("closed"); };
// wait a moment
socket.send("Hello, world!");
Accessing from Outside Localhost
When you configure WatsonWebsocket to listen on 127.0.0.1
or localhost
, it will only respond to requests received from within the local machine.
To configure access from other nodes outside of localhost
, use the following:
- Specify the exact DNS hostname upon which WatsonWebsocket should listen in the Server constructor. The HOST header on incoming HTTP requests MUST match this value (this is an operating system limitation)
- If you want to listen on more than one hostname or IP address, use
*
or+
. You MUST:- Run WatsonWebsocket as administrator for this to work (this is an operating system limitation)
- Use the server constructor that takes distinct hostname and port values (not the URI-based constructor)
- If you want to use a port number less than 1024, you MUST run WatsonWebsocket as administrator (this is an operating system limitation)
- If you listen on an interface IP address other than
127.0.0.1
, you MAY need to run as administrator (this is operating system dependent) - Open a port on your firewall to permit traffic on the TCP port upon which WatsonWebsocket is listening
- You may have to add URL ACLs, i.e. URL bindings, within the operating system using the
netsh
command:- Check for existing bindings using
netsh http show urlacl
- Add a binding using
netsh http add urlacl url=http://[hostname]:[port]/ user=everyone listen=yes
- Where
hostname
andport
are the values you are using in the constructor
- Check for existing bindings using
- If you are using SSL, you will need to install the certificate in the certificate store and retrieve the thumbprint
- Refer to https://github.com/jchristn/WatsonWebserver/wiki/Using-SSL-on-Windows for more information, or if you are using SSL
- If you're still having problems, please do not hesitate to file an issue here, and I will do my best to help and update the documentation.
Version History
Please refer to CHANGELOG.md for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
-
.NETFramework 4.6.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (19)
Showing the top 5 NuGet packages that depend on WatsonWebsocket:
Package | Downloads |
---|---|
BigQ.Client
BigQ is a messaging platform using TCP sockets and websockets featuring sync, async, channel, and private communications. This package includes the BigQ client and associated libraries. |
|
BigQ.Server
BigQ is a messaging platform using TCP sockets and websockets featuring sync, async, channel, and private communications. This package includes the BigQ server and associated libraries. |
|
BigQ.dll
BigQ is a messaging platform using TCP sockets and websockets featuring sync, async, channel, and private communications. |
|
View.Models
View.io is currently in BETA. Database models and supporting classes for View.io services. |
|
BigQ.Core
BigQ is a messaging platform using TCP sockets and websockets featuring sync, async, channel, and private communications. This package includes the BigQ core libraries. Please also download the BigQ.Client or BigQ.Server package as needed. |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on WatsonWebsocket:
Repository | Stars |
---|---|
silahian/VisualHFT
VisualHFT is a cutting-edge GUI platform for market analysis, focusing on real-time visualization of market microstructure. Built with WPF & C#, it displays key metrics like Limit Order Book dynamics and execution quality. Its modular design ensures adaptability for developers and traders, enabling tailored analytical solutions.
|
|
nulastudio/NetBeauty2
Move a .NET Framework/.NET Core app runtime components and dependencies into a sub-directory and make it beauty.
|
|
ME3Tweaks/ME3TweaksModManager
Mod Manager for Mass Effect Original Trilogy and Mass Effect Legendary Edition
|
|
codengine/SOTFEdit
A Sons of The Forest Savegame Editor
|
Version | Downloads | Last updated |
---|---|---|
4.1.2 | 12,467 | 5/1/2024 |
4.1.1 | 5,613 | 3/10/2024 |
4.1.0 | 153 | 3/7/2024 |
4.0.11 | 50,200 | 6/28/2023 |
4.0.10 | 8,475 | 5/23/2023 |
4.0.9 | 968 | 5/10/2023 |
4.0.8 | 3,586 | 2/24/2023 |
4.0.6 | 4,099 | 1/31/2023 |
4.0.4 | 8,225 | 1/2/2023 |
4.0.3 | 511 | 12/16/2022 |
4.0.2 | 334 | 12/16/2022 |
4.0.1 | 2,050 | 11/22/2022 |
3.0.2 | 5,914 | 10/24/2022 |
3.0.1 | 12,202 | 8/8/2022 |
2.3.5 | 6,288 | 8/8/2022 |
2.3.4 | 2,511 | 7/11/2022 |
2.3.3 | 625 | 7/2/2022 |
2.3.2.6 | 5,531 | 5/17/2022 |
2.3.2.5 | 8,865 | 2/7/2022 |
2.3.2.1 | 8,336 | 11/12/2021 |
2.3.2 | 3,373 | 10/15/2021 |
2.3.1 | 2,283 | 9/21/2021 |
2.3.0 | 16,263 | 4/15/2021 |
2.2.1.3 | 3,003 | 2/16/2021 |
2.2.1.2 | 433 | 2/15/2021 |
2.2.1.1 | 527 | 2/15/2021 |
2.2.1 | 479 | 2/15/2021 |
2.2.0.13 | 4,765 | 12/26/2020 |
2.2.0.12 | 593 | 12/17/2020 |
2.2.0.11 | 859 | 12/15/2020 |
2.2.0.10 | 684 | 12/7/2020 |
2.2.0.9 | 506 | 12/4/2020 |
2.2.0.8 | 734 | 11/16/2020 |
2.2.0.7 | 532 | 11/16/2020 |
2.2.0.6 | 536 | 11/16/2020 |
2.2.0.5 | 711 | 10/20/2020 |
2.2.0.4 | 657 | 10/14/2020 |
2.2.0.3 | 526 | 10/14/2020 |
2.2.0.2 | 557 | 10/14/2020 |
2.2.0.1 | 745 | 9/18/2020 |
2.2.0 | 669 | 9/10/2020 |
2.1.7.2 | 32,895 | 5/19/2020 |
2.1.7.1 | 819 | 5/18/2020 |
2.1.7 | 913 | 5/16/2020 |
2.1.6 | 2,723 | 5/11/2020 |
2.1.5 | 3,179 | 4/6/2020 |
2.1.4 | 12,174 | 3/29/2020 |
2.1.3 | 10,057 | 3/13/2020 |
2.1.2 | 1,000 | 3/12/2020 |
2.1.1 | 668 | 3/12/2020 |
2.1.0 | 578 | 3/12/2020 |
2.0.2 | 44,927 | 12/9/2019 |
2.0.1 | 12,859 | 9/21/2019 |
2.0.0 | 2,354 | 9/5/2019 |
1.3.0 | 1,257 | 8/28/2019 |
1.2.7 | 641 | 8/23/2019 |
1.2.6 | 608 | 8/22/2019 |
1.2.5 | 683 | 6/13/2019 |
1.2.4 | 4,878 | 3/11/2019 |
1.2.3 | 1,126 | 12/19/2017 |
1.2.2 | 975 | 9/8/2017 |
1.2.1 | 988 | 8/14/2017 |
1.2.0 | 1,007 | 7/12/2017 |
1.1.1 | 1,012 | 7/1/2017 |
1.1.0 | 972 | 6/26/2017 |
1.0.3 | 2,863 | 3/10/2017 |
1.0.2 | 980 | 3/10/2017 |
1.0.1 | 987 | 3/10/2017 |
1.0.0 | 1,051 | 3/8/2017 |
Retarget to include net8.0.