none
Cannot receive messages with SignalR Core2.1 and strongly typed Hub<> RRS feed

  • Question

  • Hi. I am using ASP Core 2.1 and SignalR for Core 2.1 correspondingly. Also I have WPF client with the same version of SignalR. And I want these 2 apps to communicate with each other.

    I created strongly type hub and use it as following:

    public class ProductsHub : Hub<IProductsHub>
        {
            private readonly IProductService productService;
    
            public ProductsHub(IProductService productService)
            {
                this.productService = productService;
            }
    
            public async Task GetProducts(string language)
            {
                var products = new List<ProductDTO>();
                products.Add(new ProductDTO(){ProductName = "Name"});
                await Clients.Caller.GetProducts(products);
            }
    }

    And On Client I am waiting message like this:

    ...
    public event Action<List<ProductDTO>> GetProducts;
    
    ...
    
    
    _connection.On<List<ProductDTO>>(nameof(IProductsHub.GetProduct), x =>
                {
                    Application.Current.Dispatcher.InvokeAsync(() =>
                        {
                            GetProducts?.Invoke(x);
                        });
                });

    Connection establishing correctly and method on hub is also invoked, but I dont receive message on client.

    BUT... on the same time If I will use non-typed Hub and call method via SenAsync(), I will receive this message.

    What I am missing here? Could anyone point me in the right direct, please?


    Monday, July 23, 2018 9:40 PM

All replies

  • Hi Black_Joker,

    Thanks for your post.

    This forum is used to discuss about WCF Developing issue, your issue is more related with .NET Core and SignalR, I would suggest you post your issue below:

    https://forums.asp.net/1255.aspx/1?ASP+NET+Core

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 24, 2018 7:09 AM