7.2 How to Create a WebSocket Client in C# - Fun with WebSockets!

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • In this video, I explain how to write a simple WebSocket client in C# using the WebSocketSharp library.
    This video is part of the series "Fun with WebSockets! 🌐🔌", taught by @garciadelcastillo on @ParametricCamp.
    📝Course playlist: • Fun with WebSockets! 🌐🔌
    Remember to subscribe and turn notifications on to receive alerts for new streams and content! 😄
    💻Code: github.com/Par...
    🔗 Websocket Echo Server on Glitch.com: glitch.com/edi...
    🔗 p5.js Sketch: editor.p5js.or...
    🔗 p5.js Sketch on Glitch.com: glitch.com/edi...
    Follow:
    📺 / parametriccamp
    📷 / parametriccamp
    🐦 / parametriccamp
    💻github.com/Par...
    📷🕺 / garciadelcastillo
    🐦🕺 / garciadelcasti
    📼✂️🕺Video editing: / kh.arastoo

Комментарии • 59

  • @alexvetrov3438
    @alexvetrov3438 2 года назад +3

    after 2 hours trying of different approaches your solution is WORKing for me, thank you!

  • @ArconWell
    @ArconWell 3 года назад +2

    I'm doing my senior thesis (real time chat) and you helped me a lot with understanding WebSockets. Thank you from all of my heart

  • @TeemoPwnstar
    @TeemoPwnstar 2 года назад +1

    Exactly what I was looking for and presented excellently. Thank you!

  • @criptovida
    @criptovida 2 года назад

    The best coding explanation ever, the way you break down the smaller concepts makes it super easy. Thanks for sharing.

  • @harryminnie6
    @harryminnie6 3 года назад +1

    Sir, you are a life saver. I am working on a project for a client and they require something very similar to this.

  • @btc76
    @btc76 3 года назад

    Thank you thank you thank you !! I cannot tell you how many hours I've spent looking for a websocket client example in C#. This video is just what I needed to get started, and I followed your example to the letter with the exception that I wanted to use a wss:// stream, and it works great! I've subscribed and will be checking all the related videos. Big thanks again!

  • @a.porteghali7402
    @a.porteghali7402 3 года назад

    You know, I read somewhere "“Simple is power. Simplicity comes out from the synthesis of experience and wisdom. Simple is natural, easy, nice, unpretentious.”
    : By Alex Rovira" . Your teaching style is wonderful. Thank you.

  • @yamz2281
    @yamz2281 2 года назад

    It helped me a lot not only to implement WS server and client, but also to understand these principles in general. Big thanks to you!

  • @damiancalderon3146
    @damiancalderon3146 Год назад

    awesome video Luis! I love your english and the way you explain everything.

  • @MessingWithCode
    @MessingWithCode 2 года назад

    Thanks brother , greatings from Dominican Republic

  • @dantedev3694
    @dantedev3694 3 года назад +1

    This is what I was looking for... THANK YOU SO MUCH!!

    • @gordonbentley1476
      @gordonbentley1476 3 года назад

      i realize I'm quite off topic but do anyone know of a good place to watch new movies online?

    • @carloshenry2188
      @carloshenry2188 3 года назад

      @Gordon Bentley i would suggest Flixzone. Just google for it :)

  • @azizkale6745
    @azizkale6745 2 года назад

    You are really perfect man, you saved me from my nightmares

  • @manuprakash8456
    @manuprakash8456 2 года назад

    Amazing tutorial, simple and straight forward. Now, I am having deficulty streaming using "auth token"

  • @RohitSharma-xo1vq
    @RohitSharma-xo1vq Год назад

    Great Work sir. Thank you.

  • @sekmanimohamedamine1237
    @sekmanimohamedamine1237 3 года назад

    I enjoyed in watching this tutorial, thanks.

  • @mirandabialek8432
    @mirandabialek8432 2 года назад

    thank you!! this was super helpful

  • @finishsuffering
    @finishsuffering Год назад +1

    Hi! Very useful video! I still have two unresolved issues:
    1) How do I send a message from the server to one specific client? For example, I want a message from the server to come only to one client, and not to all.
    2) The client can only accept the 'message' event. Then how do I implement chat rooms?
    THANX!

  • @theemerson64
    @theemerson64 3 года назад

    Awesome video, i really enjoyed this video.

  • @cockswell9076
    @cockswell9076 3 года назад

    Thank for the video, this saved many time

  • @yazanal-tamimi1145
    @yazanal-tamimi1145 3 года назад

    Well explained ✌✌

  • @madhusoodhanan182
    @madhusoodhanan182 2 года назад +1

    Is this code will work if the client is windows service bcs I am able to send message from windows service to websocket server but unable to receive data from server to client written in windows service

  • @unknownguy5559
    @unknownguy5559 3 года назад

    very well explained thank you

  • @mukeshmohanty4001
    @mukeshmohanty4001 3 года назад +1

    can you tell which library is better websocket-sharp or websocket4net both performance and stability wise?

  • @nikolaosb4135
    @nikolaosb4135 9 месяцев назад

    WebSocketSharp-NonPreRelease is deprecated. Is there another NuGet package I should use instead?

  • @cloudchen0831
    @cloudchen0831 9 месяцев назад

    Thanks, What if i need to make a secure connection over TLS?

  • @sergsergesrgergseg
    @sergsergesrgergseg 3 года назад +1

    Do you have to manually implement a heartbeat?

  • @TheJou1001
    @TheJou1001 3 года назад

    I suggest making a video using Signal R

  • @gibbytravis
    @gibbytravis 3 года назад

    The WebSocket class implements IDisposable, but for some reason I cannot call Dispose on my WebSocket object. I get a compiler error: "CS1061 'WebSocket' does not contain a definition for 'Dispose'" How is that possible?

  • @DeepakPal-sy9sp
    @DeepakPal-sy9sp Год назад

    🎯 Key Takeaways for quick navigation:
    00:00 📚 The video teaches how to create a WebSocket client in C# to connect to a WebSocket server and exchange information.
    01:58 📦 The "WebSocketSharp" library simplifies WebSocket communication in C#, making it easier to work with web sockets.
    03:25 🛠️ The library can be added via NuGet, simplifying the process of incorporating external dependencies into a project.
    07:46 📡 The video demonstrates connecting the WebSocket client to a server and sending/receiving messages.
    12:12 🔄 Utilizing event handlers in C# allows efficient handling of WebSocket client events like receiving messages from the server.
    Made with HARPA AI

  • @nareshkumar464
    @nareshkumar464 Год назад

    What is the best library for dotnet core to connect websocket??

  • @danielpW5673
    @danielpW5673 2 года назад

    Can you also show how to use it with a certificate? I looked at the git repo but it is a bit vague. It works when I use it with a c# server-client but it doesn't work anymore when I use html (js).

  • @dgteam1023
    @dgteam1023 3 года назад

    Does scope only works with "using" or is it possible that we make a non static class where we call the websocket from, would this in this way be still scoped and not stay in memory? thanks

  • @Konichoua
    @Konichoua 3 года назад +1

    This lib is not compatible with C# 9.0

  • @HimanshuSharma-fs6xb
    @HimanshuSharma-fs6xb 2 года назад

    Sir Please suggest any video for secure web socket as a server in C#.

  • @saeedsaimonable
    @saeedsaimonable 3 года назад

    Ur the best

  • @salmidjedjiga609
    @salmidjedjiga609 3 года назад +1

    i use the class library to make a plugin unity and i use .NET core 3.1 to send a websocket. when i make the both with .NET core 3.1 i have this error:
    Assembly 'Assets/Scenes/MonProjet.dll' will not be loaded due to errors: Unable to resolve reference 'websocket-sharp'. Is the assembly missing or incompatible with the current platform? Reference validation can be disabled in the Plugin Inspector.,i use the class library to make a plugin unity and .NET core 3.1 to send a websocket. when i make the both with .NET core 3.1 i have this error:
    Assembly 'Assets/Scenes/MonProjet.dll' will not be loaded due to errors: Unable to resolve reference 'websocket-sharp'. Is the assembly missing or incompatible with the current platform? Reference validation can be disabled in the Plugin Inspector.
    Have you any idea how to resolve that, please?

    • @tadeuszlorkowski1096
      @tadeuszlorkowski1096 3 года назад +1

      Yeah. The creator of this library created a paid Unity version. If the free version is used, it somehow creates a compile error. And even if you do have money, tough - it's delisted.

    • @salmidjedjiga609
      @salmidjedjiga609 3 года назад

      @@tadeuszlorkowski1096thank thank you for your reply, I have used an other one and it worked.

    • @saalmoi
      @saalmoi 2 года назад

      @@salmidjedjiga609 Hello! would u tell me which one is the one compatible with unity? ty btw!

  • @JohnGrove310
    @JohnGrove310 3 месяца назад

    Isn't WebSocket an abstract class?

  • @mohamedarafath4165
    @mohamedarafath4165 Год назад

    Hi Thanks for the video . I have requirement on sending Token to the service using client socket . can you share some code on how to attach Token value with subscription ?

  • @makoy2285
    @makoy2285 3 года назад

    Is there a way to implement this on web api controller rather than a console app?

  • @abdalarmden7382
    @abdalarmden7382 2 года назад

    not working to blazor-wasm pls fix

  • @abelpaz5960
    @abelpaz5960 3 года назад

    Hola! Do you know if it would be possible to create a websocket client in a ASP.NET MVC web application??

  • @zainabb2405
    @zainabb2405 2 года назад

    WHICH IDE IS BEING USED?

  • @carlostop2518
    @carlostop2518 3 года назад

    Hi!
    I've done the same things you did but the websocket client just close the connection to the server, (prabably cause of the server that doesnt send data each second but i dont know), what should i do?
    Thanks

    • @ParametricCamp
      @ParametricCamp  3 года назад

      You may want to join our Discord and post questions there, see if anyone can help you :)

  • @maheshchougule8310
    @maheshchougule8310 Год назад

    Hi, Can you please tell me regarding wss connection which is secure with browser clients? Requirement is create websocket sharp server with certificate and browser client connect to this server.

    • @sandiparora1992
      @sandiparora1992 Год назад

      I am also looking for wss connection Tutorial

  • @nathanwurtz245
    @nathanwurtz245 3 года назад

    Does this work with dotnet 5 ?

  • @amrsabbagh7708
    @amrsabbagh7708 2 года назад

    مرحبا جماعة الDIS
    فصل 2021-1

  • @muhammadfarhanmuhammadsule4376
    @muhammadfarhanmuhammadsule4376 2 года назад

    @ParametricCamp.
    not working with WSS
    any idea how to use Authorization token using this library?
    i am getting this error
    without using Authorization Token
    "Fatal|WebSocket.connect:0|WebSocketSharp.WebSocketException: An error has occurred during a TLS handshake. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The function requested is not supported"

  • @rayoseldev819
    @rayoseldev819 2 года назад

    great tutorial, but I have a big problems using websocket in my nginx server with https >.

  • @ayseryucel
    @ayseryucel Год назад

    i just want a good tutorial about websockets with .netframe work with no extra libraries. does anyone know/suggest one? (the websocketSharp on this video is already seems to be deprecated.