Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there in C# SSL WebSocket Client that is .net 4.0?

I was wondering if there is anything on this subject at the moment: I have found various examples EG: the 4.5 system.net.websockets.websocket for ssl (wss://) clients in c# and I was wondering if there were any reliable ssl versions out there since this similar question was answered.

But I am developing in Visual c# 2010, a winforms C# client application that has to receive server pushes, but it's Windows 7 so I can't us net 4.5 . (Note: the emphasis on the client)

If anyone has any actual code for SSL (hopefully one that doesn't necessarily enforce the certificate authentication prompt) I would appreciate it - I prefer code samples - but I'll take a namespace solution.

Thanks in advance:-)

like image 743
conners Avatar asked Sep 09 '25 23:09

conners


2 Answers

Websocket4net is working with SSL, we are developing a system with Jetty/websocket on server side. This is a sample snippet with authentication:

webSocket = new WebSocket("wss://host:8443/", "echo", null,
new List < KeyValuePair < string, string >> () {
    new KeyValuePair < string, string > ("Authorization", "Basic YWRtaW46YWRtaW4=")
}, "", WebSocketVersion.Rfc6455);
webSocket.EnableAutoSendPing = true;
webSocket.AllowUnstrustedCertificate = true;

The question is very old, but this answer helps others...

like image 150
crazyman Avatar answered Sep 12 '25 14:09

crazyman


So you can use .NET 4.5 in Windows 7, you just need to download the right version (on msdn.com it has the dl for Win 8) of Visual Studio.

Example connection

Example of Working with a TCP Version

General WebSocket documentation

like image 42
Brad Semrad Avatar answered Sep 12 '25 13:09

Brad Semrad