Closed hasancaktar closed 10 months ago
This library relies on the underlying http.sys implementation. Meaning we simply abstract the Websocket capabilities of the framework and OS.
then should I change the websocket versions supported by the operating system? If this is the solution, how should I make this change?
Which framework/runtime and operating system are you using?
I am using Windows 11 operating system and I am using .net core runtime. I used android device, postman programs as client. I can send you more detailed information if you want. photo video etc.
Hi @hasancaktar I wasn't able to find anything about what versions are supported on Windows. Honestly I'm not sure how to even approach this problem! Marking as 'help wanted'.
I shared the server codes I tested. maybe i am doing something wrong. Can you review please. I updated the issue. I detailed the error.
` using System.Net.WebSockets; using System.Text; using WatsonWebsocket;
namespace AppServer_Watson { internal class Program {
static string hostName = "127.0.0.1";
static int port = 8080;
static bool ssl = false;
private static WatsonWsServer server = new WatsonWsServer(hostName, port, ssl);
static List<Guid> clients = new List<Guid>();
static void Main(string[] args)
{
server.ClientConnected += ClientConnected;
server.ClientDisconnected += ClientDisconnected;
server.MessageReceived += MessageReceived;
server.Start();
Console.WriteLine($"Server Started... Hostname: {hostName}:{port} | SSL: {ssl}\n");
Console.ReadLine();
}
static void ClientConnected(object sender, ConnectionEventArgs args)
{
clients.Add(args.Client.Guid);
Console.WriteLine("\nClient connected: " + args.Client.ToString());
var client = clients.Last();
server.SendAsync(client, "Welcome", WebSocketMessageType.Text);
Console.WriteLine("All clients: "+clients.Count +"\n");
}
static void ClientDisconnected(object sender, DisconnectionEventArgs args)
{
Console.WriteLine("\nClientdisconnected: " + args.Client.ToString());
clients.Remove(args.Client.Guid);
Console.WriteLine("All clients: " + clients.Count + "\n");
}
static void MessageReceived(object sender, MessageReceivedEventArgs args)
{
Console.WriteLine("Received message: "+ Encoding.UTF8.GetString(args.Data)+" | "+"Client: "+ args.Client.ToString());
foreach (var client in clients)
{
server.SendAsync(client, Encoding.UTF8.GetString(args.Data), WebSocketMessageType.Text);
}
}
}
}`
@hasancaktar This line is the problem:
The HttpWebSocket provide by Microsoft .NET library only allow WebSocket 13 version. RFC 6455: The WebSocket Protocol. @jchristn try to handle WebSocketException
in WatsonWebsocket.cs
line 425
for show error message and close connection.
Take a look at this question. SAlu2s
@hasancaktar This line is the problem: The HttpWebSocket provide by Microsoft .NET library only allow WebSocket 13 version. RFC 6455: The WebSocket Protocol. @jchristn try to handle
WebSocketException
inWatsonWebsocket.cs
line425
for show error message and close connection. Take a look at this question. SAlu2s
Yes, this is the source of my problem. Thank you my friend for finding the problem. I don't have my computer with me right now so I can't control it. I wonder if we can adjust for all versions here. Or can we remove version control completely?
Hi @hasancaktar just to be clear, that line of code is in the underlying platform (which WatsonWebsocket sits on top of) so I don't have the ability to modify it.
Hi @MacKey-255 I love the suggestion and will implement the appropriate exception handler for this. Thank you!
Moving this to discussion as there is unfortunately nothing that we can do about it.
First of all, thank you very much for developing such a great project. It only supports version 13. I would love to have it set for all websocket versions. I want it to connect to all websokcet versions without version checking. Tools I use: Postman, Hercules. I used the XiaoFeng Library. this library supports them all. You can try
OS Win10 .net 7.0 runtime
connecting with protocol version 13
Not connection
XiaoFeng package