Intro to SignalR in C# Part 2 - Beyond Chat Applications

Поделиться
HTML-код
  • Опубликовано: 27 июл 2024
  • SignalR is for more than just chat applications. In our last video, we saw the standard demo for SignalR, where we could connect multiple clients to a chat hub. In this video, we are going to extend that demo by adding a second hub. This one will trigger the counter on the Blazor page from our WPF project.
    Full Training Courses: IAmTimCorey.com
    Source Code: leadmagnets.app/?Resource=Int...
    Mailing List: signup.iamtimcorey.com/

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

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

    Tim, thank you for demystifying SignalR. Great tutorials as always. Much appreciated.

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

    Thanks for this. I thought part 2 would take longer but you pulled it off so quickly. Going to allocate some time to absorb your knowledge fully.

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

    Another great video. Thanks Tim. It takes so much time and effort to create this type of tutorial. Thanks again.

  • @codefoxtrot
    @codefoxtrot 2 года назад +12

    Thanks Tim! Looking forward to parts 3, 4, 5 & 6... or better yet a published course on your site for more of this. These first two parts were definitely a great ice-breaker, at least for me, since I hadn't yet explored SignalR. Sometimes you have to turn off the learning, in favor of getting stuff done. Nevertheless, your videos always save me time compared with self-learning, so when I saw the notification for SignalR Part 1, I couldn't resist. So thanks again!

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

      Thank you! And thanks for the suggestion.

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

      we need mroe for signalR. Maybe u may say about how to store messages so every new client can connect and see messages when he was not avilable. Moreover same scenario just when particural user send to any other specific user like in the chat app like Whatsup.

    • @DavidMartin-vs1dm
      @DavidMartin-vs1dm 9 месяцев назад

      How to send to specific clients would be great.

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

    Thank You.. It is just Iftar gift for me.. I can't watch this right now... I will watch after Ramadan Iftaar.. Thank You Tim Corey ❣❣

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

    What a great tutorial. Thank you so much. I will love to see the advance part where one can send message to specific client

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Very nice work!!! As always great!

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

    Thanks for the help this video provided! I'd love to see a video about what security, authentication, authorization, etc. is available in SignalR, and how to implement them.

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Hi Tim !You are doing an excellent job , but in this video I was waiting to see how to send data to specific users not to everyone equally. hope to make a video for this. Thanks !!

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Thanks Tim.
    Blazor is powerful.

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

      You are welcome.

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

      @@IAmTimCorey
      Using Signal R how to display a driver locations on the map like uber ?

  • @Simnico99
    @Simnico99 2 года назад +11

    Really great video, I've learned alot about signalR but I would like to know how to broadcast to only a certain amount of people like admins recieving notifications about something etc.

    • @aah134-K
      @aah134-K 2 года назад

      Track them when signal r connect, with a dictionary forexample user to connectio. Id, user roles to connection ids and so fourth. When you want to prodcast to admin get all admin "whom are connected" and send message to thwm

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

      You can add the admins to a group and send whatever message to them.
      Or track admins with a database or dictionary

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

    I agree: that would be a great Part 3.

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

      What are you looking for in part 3?

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

      @@IAmTimCorey Sorry, I was meaning to put that in reply to @Simnico99's (ruclips.net/channel/UCQRVFuD0t68EyxV8Hl0Ypfg) comment asking about "how to broadcast to only a certain amount of people like admins receiving notifications about something etc." It was not meant to be a top-level comment. ☺️

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

    thank you for the 2 part series, good intro to Blazor and SinglR. The only issues i had was an outdated Visual Studio and the restrictions my organization placed on my laptop where I couldn't run the WPF App. Even though I have admin rights it keeps saying "Access Denied".

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

    Great presentation. Thanks! Would love to see signalR authentication covered at the same level. Subscribing!

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

  • @ranielgarcia8685
    @ranielgarcia8685 2 года назад +2

    Hey Tim, Thank you for this tutorial again!
    Can we use SignalR for trading applications?

  • @manwatermelon
    @manwatermelon 2 года назад +4

    Hey, Tim! Would be great to understand how to send the messages to specific clients. Imagine whispers or private messages on chat apps.

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    how do we save this information? Let's say a user closes its client, and open it back up, How can the user see where they last left off from?

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

    Thank you for a short and clear work. If I need a web app on the client side, can I create a ASP razor page app as client to be run on non windows device?

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

      Yes, you can. You can also create a JavaScript client (no C#) or clients in other languages.

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

    Hi, Tim.
    I would like to avoid "magic strings" in the method names. What's the best practice? Using interfaces, for instance?

    • @IAmTimCorey
      @IAmTimCorey  2 года назад +2

      Probably just string constants, maybe in a shared library so that other projects can use the same constants. It won't solve all of the naming issues, though, since some are method names that then correspond to strings. For that, you might try "nameof()", but that might get hacky.

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

    Great as usual. I've just one request if you can explain the SignalR + Newtonsoft.Json or MessagePack protocols. Thanks

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Hi Tim, thank you for the video. I need to know more about where to host my application using SignalR with maybe 100 users connected at the same time and chatting and playing together. And also some information about Azure SignalR pricing. Thanks

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

      You can host your app anywhere with just 100 concurrent connections. That's not really a big deal. 10,000 would be where I would start looking for other solutions. However, if you want to offload your SignalR connections anyway, you could do so for $50/month if you hosted on East US: azure.com/e/62513f4b4772453ab8a051795e515784
      Note that this plan covers 1,000 concurrent connections and gives you 1,000,000 messages for free before it starts charging you for additional messages.

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

    thank you tim for your awesome educational content. i have a question about writing tests for signalR. is there a recommending way to write tests rather than just mocking in unit tests? for example is it a good idea to bring up all dependencies with docker and test if chatHub is working properly?
    im asking this because all the time my frontend says that something on serverSide is not working properly and then i should test my release on stage server by bringing up a console app(using Microsoft.AspNetCore.SignalR.Client) which acts as the client and test the stage server like that.

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

      Unit tests test just one unit of work. They don't test the interconnected system. It sounds like you are wondering about end-to-end testing. That can be a good thing, although it is tricky to get right, expensive to build, and it will be constantly changing. That means that you don't do it very often and you don't do many of them. The way to do it would probably be to spin up a full setup in Docker or something else where you can reset the environment easily.
      However, in this specific case, it sounds more like you are having a problem in production and need to track down what is going wrong. In that case, good logging is a better option. That way, you can read through the logs and identify what went wrong.

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

    Waiting for part three😁

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

      There isn't a part 3 scheduled. What would you like to see in a part 3?

  •  2 года назад

    Hi, nice video, thanks. One important feature that was not mentioned is the capability to send menssages to a specific user, even if the user is not logged in. Like send a message for a specific visitor session on a website...

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

      I mentioned it but I did not show it. That's a more complicated process that would have been too long to add to a video. It would need to be its own video.

    •  2 года назад

      @@IAmTimCorey Hi, thanks so much for answering. Actualy I've already done sending individual messages... had to find out how to do it on my own, but it would be a very good video to make. A whole series on SignalR. It's a very good tool with so many applications...

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

    Great demo of SignalR - I have done Tim's Blazor Server course which also demos SQL connections. I just wondered whether Tim could demo using SignalR to stream data from the data base. Also I'm interested in using SignalR to receive location data from a mobile phone and the display this real time on a google map - any thoughts on this?

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

  • @ayanpoddar5041
    @ayanpoddar5041 2 года назад +2

    please more videos about signal r.
    and what other compression is able out of the box and which one best??

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Would love to see a video on broadcasting changes from and SQL Server database to connected clients.

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    A third part would be nice regarding to use signalR with javascript in the client.

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Hi Tim, is there any difference between InvokeAsync(StateHasChanged) and StateHasChange()

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

      InvokeAsync is needed when you know that the code might be executed on a background thread and the code modifies components/objects owned by the UI thread. Without InvokeAsync you will run into exceptions being thrown if you try to run StateHasChanged from a thread other than the main UI thread.

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

    Hi Tim, Thanks for these SignalR videos. Your sample works fine when I run it on one machine with the server app running from Visual Studio. But I get a 'No connection could be made because the target machine actively refused it. (localhost:7181)' when I run the WPF app on another machine on same wifi. Have you got a tip?

    • @diegoronkkomaki6858
      @diegoronkkomaki6858 2 года назад +2

      Running multiple devices on the same wifi network does not mean you can connect to other devices localhost. Each device has their own localhost, you can think of localhost as the current device itself. So your WPF application is trying to connect to a server running on that same specific device, but fails, because there is no server running on the WPF machine's localhost.

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

      The best thing to do would be to publish your SignalR server to a web server. They are designed to be reachable by other machines on the network, or even across the Internet. You can set up your local machine to be a web server. This video will show you how: ruclips.net/video/PPaqVyBkwMk/видео.html Just note that you will then need to make sure your local machine's firewall permits access on the correct ports, plus you will need to add a SSL certificate on your local machine that the other machines trust, plus you will need to access your machine remotely using your machine's IP address. As @Diego pointed out, the word "localhost" represents the machine you are on. That doesn't work when you want to access a remote machine. In that case, you would access it by the IP address.

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

    Great video! Question: How do I get Vs2022 to insert Pattern: Method: Page: etc ? @IAmTimCorey

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

    Thanks for the video. I added .MAUI project in worked well in windows application but Android real device and emulator didn't.
    adb reverse tcp:7181 tcp:7181
    Used above to get access localhost:7181 but got following error message "java.security.cert.CertPathValidatorException: Trust anchor for certification path not found"
    Do you might know what to do next? Do I need self signed certificate? Override some security classes?? Change some security options? Kind of stuck. Self signed certificate sounds next to try.

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

      It sounds like your emulator does not trust the certificate. Self-signing won't change that (you already have a self-signed certificate for your API). What you need to do is trust that certificate. That would be my guess.

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

    Thanks

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

    Hi Tim, can you make a video for Signal R connection with angular?

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Let's imagine that I have Web API and additionaly SignalR for notifications.
    - Is there a way to share authentication data between those 2 server side services ?,
    - Do I need to invoke SignalR method from client side (frontend: update something via Web API method, than send notification) or I can do it from backend (frontend: update something via Web API method (for ex. ApproveFollower), backend: inside Web API method ApproveFollower, send a notfication to the follower user via SignalR) ?

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

      Yes, they can share authentication. Yes, you can alert the clients from the server. You can't establish a connection from the server to the client, though. The client needs to be the one to establish a connection.

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

    A single NIC is limited to 65536 simultaneous connections IIRC. What's available for web sockets would be slightly less.

    • @IAmTimCorey
      @IAmTimCorey  2 года назад +2

      I think this is a confusion on network ports vs network connections. You can (and do) have multiple connections over one port. Web servers, for instance, usually use port 443 for serving a website, yet they can have more than one visitor at a time. A network card has roughly 65,000 ports that can be used simultaneously. For instance, on the same server you can be using FTP on port 21. With SignalR, you are using the web communication channel (usually port 443) for all communication. Inside of it, you can have multiple WebSocket connections at once. By default, IIS limits you to 5,000 connections per CPU, but you can increase that dramatically. The bottleneck, though, will be the server's ability to keep track of all of those links. Even the bandwidth won't really be a problem, since you usually send very small packets across the wire. 100,000 clients sending 1kb packets would only result in a 100MBps transfer rate. It is a rare business that cannot sustain that much traffic to their commercial site. That's why the bigger problem is the computer driving all of those changes at once. It will have a lot of bottlenecks trying to talk to 100,000 clients at once.

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

      ​@@IAmTimCorey You're right of course, excuse the brain fart! Thanks for the videos! I tried out gRPC per another of your videos to make a client/server app (both in winforms) so I could send keystrokes I hooked from a VMware guest to the host so my multimedia keys would function on my host. It took forever to figure that out because when your mouse is hovering over a VM window, VMware will hijack the keydown/up messages you want to send via SendMessage and send those messages back to the guest, creating an endless loop!. I finally figured that out, but ended up ditching gRPC and using SignalR because I got stuck on an issue with gRPC not working in Win7 VMs due to an http/ssl version issue I think. I figured I'd give SignalR a shot to learn a bit about it. I don't think I'll ever try gRPC again just because I didn't like the gotchas you warned us about, because they got me even after your warning.

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

    Could you send the github link for this sample?

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

      I don’t have a GitHub link. There is a link in the description to download the source.

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

    Part 3, UI dashboard please?

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Otherthan WPF, Can this work with winform project type as a client?

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

      Sure. It can work with almost any client.

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

      @@IAmTimCorey Thanks

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

    How to publish SignalR on Heroku?

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

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

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

    Tim, do you have any resources on working with groups and how to send messages to specific groups of users and connection pools? I have it working somewhat, but the amount of messages being dropped is astronomically high. Approximately half or more messages are dropped so I think I may be doing something incorrectly.

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

      I don't have an example of that yet, sorry.

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

      @@IAmTimCorey Okay. I have been fighting with setting up Azure SignalR via a deployed API and connecting to receive messages via a JavaScript client. Talk about a headache.