Questions tagged [system.net.websockets]

The System.Net.WebSockets namespace provides a managed implementation of the WebSocket interface for developers.

The namespace provides a managed implementation of the WebSocket interface for developers.

Some of the classes in the namespace are supported on Windows 7, Windows Vista SP2, and Windows Server 2008. However, the only public implementations of client and server WebSockets are supported on Windows 8 and Windows Server 2012. The classes and class elements in the System.Net.WebSockets namespace that are supported on Windows 7, Windows Vista SP2, and Windows Server 2008 are abstract classes. This allows an application developer to inherit and extend these abstract classes with an actual implementation of client WebSockets.

MSDN link: http://msdn.microsoft.com/en-us/library/vstudio/system.net.websockets

19 questions
8
votes
0 answers

Why can't a closed ClientWebSocket be reopened without a creating a new instance of the ClientWebSocket?

I'm currently working on a System.Net.WebSockets implementation that will be using cellular networks to send data packets about the device in a real-time manner. Using cellular network means that my solution should be able to reconnect a socket when…
awatson
  • 81
  • 1
  • 6
8
votes
2 answers

c# Detect when ClientWebSocket is disconnected (closed)

After a long search i come to you to help me. I have a WPF application, use ClientWebSocket class (using System.Net.WebSockets) to connect to WebSocket server(NodeJS). My application is running backgroung windows application, it connects at first…
J-Go
  • 115
  • 1
  • 1
  • 8
6
votes
2 answers

Setting "User-Agent" HTTP header in ClientWebSocket

I need to set the "User-Agent" HTTP header in a ClientWebSocket object, but it is not possible. Although there is a ClientWebSocket.SetRequestHeader(header,value), the method fails if I try to set that header: System.ArgumentException: This header…
vtortola
  • 34,709
  • 29
  • 161
  • 263
3
votes
0 answers

Websocket server sending spontaneous messages (without requests from the client)

I must admit I may have missed something fundamental. If so, please point it out. All that follows is how I understand a websocket server. I'm trying to write a websocket server that should keep a client updated as to the status of a job they…
Simone
  • 1,260
  • 1
  • 16
  • 27
2
votes
0 answers

.NET MAUI WebSocket doesn't work on android 5 and 8

On my android 11 device my websocket works fine, but when i try to run it on older phone with android 5 or 8, it doesnt work and it only says Unable to connect to the remote server Is there some way to make it works ? I am using…
Lukas
  • 65
  • 5
2
votes
0 answers

How to trace Websocket traffic with IIS

I'm using IIS 10 and need to trace the traffic flowing in and out from the .NET 4.5.2 WebSocket that is created when someone opens a websocket to the server, this seems to be quite impossible. The current trace configuration is logging System.Net,…
Crypth
  • 1,576
  • 18
  • 32
1
vote
0 answers

WebSocketClient ReceiveAsync never completes (Mono, Linux)

I'm having trouble with WebSockets on Mono, Linux, ARM (it's a Jetson Nano, in case that matters). This example connects to a WebSocket server and then waits for the first text message that comes back, logs it and that's it. This program works…
Wyck
  • 10,311
  • 6
  • 39
  • 60
1
vote
1 answer

ASP.NET MVC Websocket server (WebAPI) handshake completing, but OnOpen and other event functions are not getting hit server side

NOTE: I am tagging this with C# as I believe it will hit a wider audience in the ASP.NET community.. If this is an issue let me know and I can remove it (C# is my preferred language, but for this project I'm forced to write in VB). The websocket…
CTDev
  • 226
  • 2
  • 12
1
vote
1 answer

TypeInitializationException when setting ServicePointManager.ServerCertificateValidationCallback with tracing off

I'm getting an unhandled TypeInitializationException exception when I try to set ServicePointManager.ServerCertificateValidationCallback += (a, b, c, d) => true; The exception happens when I've got the following (taken from MSDN) in my app.config.…
eoinmullan
  • 1,157
  • 1
  • 9
  • 32
0
votes
0 answers

c#, .net.websockets - ClientCertificate

i have a websocket client and server and i'm trying to add a certificate to my client, but i don't think i have the hang of it yet.. i have an asp.net core 7 web api and wonder what i do wrong Client: public async Task GetEcho(string…
0
votes
1 answer

Correctly sending a JSON message over WebSocket in C#

`I'm trying to send a JSON message over a WebSocket connection using C#. The message I'm trying to send is a serialized object that needs to be nested inside a JSON array. The class structure for my message is: public class BulkSubscribeMessage { …
0
votes
1 answer

Websocket Closing Handshake with a C# client and a Node.js server

I use "CloseOutputAsync" on the C# client to initiate the close handshake with the Node.js server. My Node.js server receives a "close" event and immediately sets his "websocket.readyState" as "CLOSED" without going through "CLOSING". As my C#…
Takah
  • 345
  • 3
  • 20
0
votes
1 answer

System.Net.WebSockets leaving sockets in close_wait after disconnect

I'm having issues closing a System.Net.WebSockets connection properly. After some googling even found someone that explained how to do it properly, but his own samples leave the socket in close_wait. I'll use that persons samples as his explanation…
Nico
  • 559
  • 4
  • 22
0
votes
1 answer

System.Net.WebSockets Connection OPEN before server is listening

I'm running into issues on a setup that's under load accepting the connection and setting it to OPEN before the server is read to read from the socket. Example(not the actual code): while (true) { var objContext =…
Nico
  • 559
  • 4
  • 22
0
votes
0 answers

Just need to check whether WSS server is On/Off via WSS client using .Net System.Net.WebSockets with Certificate?

Why always getting error Cannot find the requested object? See trace detail in code my comment. I need to implement WSS client and check WSS server availability using certificates. But as try to create object of X509Certificate2, getting…
1
2