locked
SignalR client hub not trigger after IIS Deployment RRS feed

  • Question

  • User786456085 posted

    I'm having a trouble in SignalR client hub. On my local IIS Express it seems working but after I deployed to IIS server

    client hub was no longer trigger events.

    Here's my Startup.cs file:

    public partial class Startup {
    public void Configuration(IAppBuilder app) {
    
    var hubConfiguration = new HubConfiguration();
    hubConfiguration.EnableDetailedErrors = true;
    hubConfiguration.EnableJavaScriptProxies = true;
    
    app.MapSignalR("/~/signalr", hubConfiguration);
    
    }
    }

    Here's my hub:

    [HubName("chartData")]
        public class ChartDataHub : Hub , IRequiresSessionState
        {
            //private readonly ChartData _pointer;
    
            //public ChartDataHub() : this(ChartData.Instance) { }
    
            //public ChartDataHub(ChartData pointer)
            //{
            //    _pointer = pointer;
            //}
    
            REPI.REPIClass.DBControlClass oDBMngr = new REPI.REPIClass.DBControlClass("DailyTakeInTakeOutMonitoring");
            SqlCommand objSQLCMD = new SqlCommand();
            DataSet dsResult = new DataSet();
            DataTable dtResult = new DataTable();
            DataTable dtResult2 = new DataTable();
            DataTable dtResult3 = new DataTable();
            string strSQL = "";
    
    
            private readonly static Lazy<ChartData> _instance = new Lazy<ChartData>(() => new ChartData());
    
    
            public readonly System.Timers.Timer _Timer = new System.Timers.Timer();
            public ChartDataHub()
            {
                _Timer.Interval = 10000;
                _Timer.Elapsed += TimerCallBack;
                _Timer.Start();
            }
    
            private void TimerCallBack(object sender, System.Timers.ElapsedEventArgs e)
            {
                GetClients().All.updateTakeInData(UpdateTRTakeInData());
            }
    
    
            //GetTakeInData
            private object UpdateTRTakeInData()
            {
                List<GetTakeInCount> lst = new List<GetTakeInCount>();
                using (SqlConnection con = new SqlConnection(oDBMngr.ConnectionString))
                {
                    con.Open();
                    strSQL = "SELECT Date,TotalPlan,TakeInQty,Order3Qty,DelayedQty FROM vewTRTakeInMonthly";
                    objSQLCMD = new SqlCommand(strSQL, con);
                    objSQLCMD.CommandType = CommandType.Text;
                    SqlDataReader rdr = objSQLCMD.ExecuteReader();
                    while (rdr.Read())
                    {
                        GetTakeInCount rowData = new GetTakeInCount();
                        rowData.TakeInQuantity = Convert.ToDouble(rdr["TakeInQty"].ToString());
                        rowData.Date = rdr["Date"].ToString();
                        rowData.PlanQuantity = rdr["TotalPlan"].ToString();
                        rowData.AccPlanQty = Convert.ToDouble(rdr["TotalPlan"].ToString());
                        rowData.OrderQty = Convert.ToDouble(rdr["Order3Qty"].ToString());
                        rowData.DelayedQty = Convert.ToDouble(rdr["DelayedQty"].ToString());
                        lst.Add(rowData);
                    }
                    return lst;
                }
            }
    
            private static dynamic GetClients()
            {
                return GlobalHost.ConnectionManager.GetHubContext<ChartDataHub>().Clients;
            }
    
            public class GetTakeInCount
            {
                public string Date { get; set; }
    
                public double TakeInQuantity { get; set; }
    
                public string PlanQuantity { get; set; }
    
                public double AccPlanQty { get; set; }
    
                public double OrderQty { get; set; }
    
                public double DelayedQty { get; set; }
    
            }
        }

    And my JS file:

    $.connection.chartData.client.updateTakeInData = function (data) {
    .................................FETCHING DATA CODE.............................
    }
    
    $.connection.hub.logging = true;
    $.connection.hub.start({ transport: ['longPolling'] });

    So, given the above, am I missing something obvious? If not, what is the best way to identify the failure point?


    Thursday, May 2, 2019 6:36 AM

All replies

  • User283571144 posted

    Hi ryan.makiling26,

    According to your description, I suggest you could post more details information about the error message.

    You could find it through the F12 develop tool.

    If you could post more details information, it will be more easily for us to find out the solution.

    Best Regards,

    Brando

    Thursday, May 2, 2019 9:42 AM
  • User786456085 posted

    Hello Brando,

    I haven't encounter any error message on IE Console. Its just that when I accessed the program, it stop here 

    DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
    File: en-ph
    HTML1300: Navigation occurred.
    File: DailyTakeInTakeOutMonitoring
    DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
    File: en-ph
    [08:52:47 GMT+0800 (Taipei Standard Time)] SignalR: Client subscribed to hub 'chartdata'.
    [08:52:47 GMT+0800 (Taipei Standard Time)] SignalR: Negotiating with '/DailyTakeInTakeOutMonitoring/signalr/negotiate?clientProtocol=2.0&connectionData=%5B%7B%22name%22%3A%22chartdata%22%7D%5D'.
    [08:52:47 GMT+0800 (Taipei Standard Time)] SignalR: Negotiating with '/DailyTakeInTakeOutMonitoring/signalr/negotiate?clientProtocol=2.0&connectionData=%5B%7B%22name%22%3A%22chartdata%22%7D%5D'.
    [08:52:48 GMT+0800 (Taipei Standard Time)] SignalR: longPolling transport starting.
    [08:52:49 GMT+0800 (Taipei Standard Time)] SignalR: Opening long polling request to 'http://localhost/DailyTakeInTakeOutMonitoring/signalr/connect?transport=longPolling&clientProtocol=2.0&connectionToken=EnhIEDeBqs%2FhU8OAFAX%2FKp3vG99XqPJjNroeM9%2FOjC7jeHWMOaIXXRTyvBroBIgUM%2FUvFFwzZ3x4zMii2cAy5uoMyXcFX3fIlYq%2FFFEGglmhTO4rzqPortt8HeV4e7hd&connectionData=%5B%7B%22name%22%3A%22chartdata%22%7D%5D'.
    [08:52:49 GMT+0800 (Taipei Standard Time)] SignalR: Long poll complete.
    [08:52:49 GMT+0800 (Taipei Standard Time)] SignalR: LongPolling connected.
    [08:52:49 GMT+0800 (Taipei Standard Time)] SignalR: longPolling transport connected. Initiating start request.
    [08:52:49 GMT+0800 (Taipei Standard Time)] SignalR: Opening long polling request to 'http://localhost/DailyTakeInTakeOutMonitoring/signalr/poll?transport=longPolling&clientProtocol=2.0&connectionToken=EnhIEDeBqs%2FhU8OAFAX%2FKp3vG99XqPJjNroeM9%2FOjC7jeHWMOaIXXRTyvBroBIgUM%2FUvFFwzZ3x4zMii2cAy5uoMyXcFX3fIlYq%2FFFEGglmhTO4rzqPortt8HeV4e7hd&connectionData=%5B%7B%22name%22%3A%22chartdata%22%7D%5D'.
    [08:52:49 GMT+0800 (Taipei Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
    

    Nothing follows. Client Hub methods won't trigger. 

    Please I need your help.

    Thank you,

    Best Regards,

    Ryan

    Monday, May 6, 2019 12:55 AM
  • User283571144 posted

    Hi ryan.makiling26,

    Nothing follows. Client Hub methods won't trigger. 

    Could you please tell me what the "Client Hub methods won't trigger" mean?

    Does it means the server doesn't trigger client method?

    I suggest you could firstly use remote debug to remote debug the application to make sure the TimerCallBack has fired.

    More details about how to remote debug the web application, you could refer to below article:

    https://docs.microsoft.com/sr-latn-rs/visualstudio/debugger/remote-debugging-aspnet-on-a-remote-iis-7-5-computer?view=vs-2015 

    Best Regards,

    Brando

    Monday, May 6, 2019 6:23 AM
  • User786456085 posted

    Sir Brando,

    Yes, the server doesn't trigger client method.

    I'll show you the client method trigger on my local.

    This is how it looks..

    HTML1300: Navigation occurred.
    File: localhost:56219
    HTML1300: Navigation occurred.
    File: StockMonitoring.aspx
    [16:04:17 GMT+0800 (Taipei Standard Time)] SignalR: Client subscribed to hub 'chartdata'.
    [16:04:17 GMT+0800 (Taipei Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22chartdata%22%7D%5D'.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: serverSentEvents transport starting.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: This browser doesn't support SSE.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: serverSentEvents transport failed to connect. Attempting to fall back.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: foreverFrame transport starting.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: Binding to iframe's load event.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: Iframe transport started.
    [16:04:18 GMT+0800 (Taipei Standard Time)] SignalR: foreverFrame transport connected. Initiating start request.
    [16:04:19 GMT+0800 (Taipei Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
    [16:04:19 GMT+0800 (Taipei Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332, keep alive timeout of 20000 and disconnecting timeout of 30000
    [16:04:23 GMT+0800 (Taipei Standard Time)] SignalR: foreverFrame transport timed out when trying to connect.
    [16:04:37 GMT+0800 (Taipei Standard Time)] SignalR: Triggering client hub event 'updateTakeInData' on hub 'chartData'.
    [16:04:39 GMT+0800 (Taipei Standard Time)] SignalR: Triggering client hub event 'updateTakeOutData' on hub 'chartData'.

    SignalR Triggering client hub. But when I deployed it to IIS 8 it stops in "foreverFrame transport time out when trying to connect."

    Thank you for your fast response.

    Ryan

    Monday, May 6, 2019 8:06 AM
  • User283571144 posted

    Hi ryan.makiling26,

    According to your error logs, I couldn't directly find out the reason.

    I guess there are some reasons caused the _Timer function isn't triggered.

    I suggest you could follow the remote debug article to see how it work after published the application to IIS.

    https://docs.microsoft.com/sr-latn-rs/visualstudio/debugger/remote-debugging-aspnet-on-a-remote-iis-7-5-computer?view=vs-2015  

    Best Regards,

    Brando

    Thursday, May 9, 2019 5:19 AM
  • User786456085 posted

    Sir Brando,

    I have changed the way I code Signal R. I used SQL dependency to trigger if the database table was modified or something. Now my problem is if there were lots of client that are connected. client hub fires multiple times and keeps multiplying if there were changes in SQL db. 

    Should I resend my code to you for you to check if there were something error in my code?

    Thank you for your responce.

    Ryan

    Thursday, May 9, 2019 6:09 AM