Open Closed

SignalR in tiered project #7448


User avatar
0
IbrahimSarigoz created

Hi, I'm working on a SignalR project and I prefer not to use a distributed event bus. I've looked at ABP samples where one uses a distributed event bus and the other only relies on the web layer. Is it feasible to implement SignalR in a distributed architecture without using an event bus?

  • ABP Framework version: v8.1.3
  • UI Type: MVC
  • Database System: EF Core (Oracle)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes tiered
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

16 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Yes, you can use SignalR for two-way communication.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    https://volosoft.com/blog/RealTime-Messaging-Distributed-Architecture-Abp-SingalR-RabbitMQ

    For example, I couldn't manage this without distributed event bus.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    This example combines distributed events and SignalR.

    You can use SignalR directly

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    Do you have any example basic project ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Yes,

    see: https://github.com/abpframework/abp-samples/tree/master/SignalRDemoBlazorUI

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    Hi, I prepare a basic abp mvc project. this is github link: https://github.com/Ibrahimsrgz/BasicSignalRApp.git

    as you know in mvc we dont have access token provider and in this example i dont want to check access provider. so i changed api.host.module a bit.

    unfortuanaly i am getting

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    HI,

    we have an MVC example, too. https://github.com/abpframework/abp-samples/tree/master/SignalRTieredDemo

    this is github link: https://github.com/Ibrahimsrgz/BasicSignalRApp.git

    please private the repo, it's includes your lienAbpLicenseCode

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    I know this MVC example. The thing is i need hub in the application layer. in this example it is in web layer.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    You can try

    /signalr-hubs/chat

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    I also try it and it gives same error

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    1
    liangshiwei created
    Fullstack Developer

    add me to the repo, i will check it

    my github username is realLiangshiwei

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    Have you had a chance to review it?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    You add the ChatHub in the HttpAPI.Host project, the client(web) needs to connect to the HttpAPI.Host You used the wrong url

    See my commit: https://github.com/Ibrahimsrgz/BasicSignalRApp/compare/fix?expand=1

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    Thanks a lot for your response and help. It works now when its allowed for anonymous

    in security part, i change hub.cs allowanonymous to Authorize and i am getting

    I pushed my repo.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    you need to pass the access_token

    for example:

    public class IndexModel : IndexModelBase
    {
        public string Token { get; set; }
        
        public IndexModel(IChatsAppService chatsAppService)
            : base(chatsAppService)
        {
        }
    
        public override async Task OnGetAsync()
        {
            Token = await HttpContext.GetTokenAsync("access_token");
        }
    }
    
    @section scripts
    {
        <script>
            var token = '@Model.Token';
        </script>
        <abp-script src="/Pages/Chats/index.js" />
        <abp-script type="typeof(SignalRBrowserScriptContributor)" />
    
    @*//<suite-custom-code-block-2>*@
    @*//</suite-custom-code-block-2>*@
    }
    
    var connection = new signalR.HubConnectionBuilder().withUrl("https://localhost:44367/signalr-hubs/chat?access_token="+token).build();
    

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    IbrahimSarigoz created

    Thank you, I get it.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.