SignalR in a Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
I'm trying to use SignalR with a product import plugin because it's going to take hours to import 50k products while downloading images, adding categories, and adding manufacturers.

I've added signalR via NuGet and have added my Startup Class as follows:

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(Nop.Plugin.Misc.CAImport.Infrastructure.Startup))]
namespace Nop.Plugin.Misc.CAImport.Infrastructure
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}

For some reason my Startup Class is not even running. Has anyone gotten SignalR to work on a nop plugin project before?
9 years ago
I got my startup class to register. I had to add the NuGet Package Microsoft.Owin.Host.SystemWeb 2.1.0 to the Nop.Web project. I tried to use a newer version but this version of Nop needs this specific version.

I'm just having a problem triggering my signalR hub from javascript.

<script type="text/javascript">
    $(document).ready(function () {
        var importHub = $.connection.importHub;

        $("#import-form").submit(function (e) {
            var fileName = $("#Location").val();

            e.preventDefault();
            //$("#import-form").hide();
            $("#status-display").show();
            importHub.server.importProducts(fileName);
        });

        $.connection.hub.start();
    });
</script>

Hub Code:

public class ImportHub : Hub
    {
        private ICAImportService _caImportService;

        public ImportHub(ICAImportService caImportService)
        {
            this._caImportService = caImportService;
        }

        public void ImportProducts(string fileName)
        {
      // Do Stuff Here

        }
    }

I just did some testing and it looks like the dependency injection is causing a problem.

This link has the solution: http://docs.autofac.org/en/latest/integration/signalr.html

Looks like I need to add code to the Global.asax but I'm not sure if this is possible to do via a plugin. Has anyone been able to solve this?

I'm trying to just add some code to my DependencyRegistar inside my plugin. I installed the NuGet package Autofac.SignalR. This package needs Autofac 3.1.3 but Nop uses a newer version of Autofac so I get an error when I build.
7 years ago
Hi,
SignalR is becoming popular. I guess next version of nopCommerce should incorporate that.
By the way, can you please share the full implementation of the plugin and where in nopCommerce you made the changes? This will help when some one is starting from scratch.
6 years ago
wmwebsites wrote:
I'm trying to use SignalR with a product import plugin because it's going to take hours to import 50k products while downloading images, adding categories, and adding manufacturers.

I've added signalR via NuGet and have added my Startup Class as follows:

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(Nop.Plugin.Misc.CAImport.Infrastructure.Startup))]
namespace Nop.Plugin.Misc.CAImport.Infrastructure
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}

For some reason my Startup Class is not even running. Has anyone gotten SignalR to work on a nop plugin project before?


Hi,
You just have to set owin:AutomaticAppStartup key value to true of appSettings in web.config of Nop.Web.

Also, I would like to know if you had successfully implemented SignalR in nopcommerce.
6 years ago
danger wrote:

Hi,
You just have to set owin:AutomaticAppStartup key value to true of appSettings in web.config of Nop.Web.

Also, I would like to know if you had successfully implemented SignalR in nopcommerce.


Hello,

I have successfully implemented SignalR in  a nopcommerce plugin.

I did not set owin:AutomaticAppStartup key value to true.

Thanks,
Tony
6 years ago
Carneno wrote:


I did not set owin:AutomaticAppStartup key value to true.



What's the version of your nopCommerce because this appsetting has been implemented from 3.70 i guess ?
6 years ago
danger,

I am using nopCommerce 3.90.

Tony
6 years ago
Carneno wrote:
danger,

I am using nopCommerce 3.90.

Tony


Nice Tony!

Can you share with me the part of loading SignalR Hubs? I am trying by <script src="/signalr/hubs" type="text/javascript"></script> . I even tried by changing the paths in script but it's no where I can locate the hubs. It always returns me 404 not found.

Thank you.
6 years ago
danger wrote:
danger,

I am using nopCommerce 3.90.

Tony

Nice Tony!

Can you share with me the part of loading SignalR Hubs? I am trying by <script src="/signalr/hubs" type="text/javascript"></script> . I even tried by changing the paths in script but it's no where I can locate the hubs. It always returns me 404 not found.

Thank you.

Did you configure the routes properly?
6 years ago
danger wrote:

Nice Tony!

Can you share with me the part of loading SignalR Hubs? I am trying by <script src="/signalr/hubs" type="text/javascript"></script> . I even tried by changing the paths in script but it's no where I can locate the hubs. It always returns me 404 not found.

Thank you.


danger,

I can send you just the parts of my plugin that you need.  Just let me know what to send you.

Or, I can send you my whole plugin if you want.  I will just take out the code that I wrote for the processing.

Let me know.

Tony
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.