Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys, I'm just wondering if anyone can help me. I have a windows service which calls the hub class in my web application. My problem is that when I create the hub context and call the display message the messages don't get displayed. The initial connection is fine and I can see from fiddler that the hub is connected.

Service code
C#
 var context = GlobalHost.ConnectionManager.GetHubContext<ClientNotificationsHub>();
context.Clients.All.DisplayMessage();


Client code
$(function () {

           var hub = $.connection.dbHub;

           hub.client.displayMessage = function () {

               alert("Success");
           };

           $.connection.hub.start().done(function () {
               var userId = '<%=Session("iUserId")%>';
               var connection = '<%=Session("sDBConnection")%>';
               hub.server.setConnection(userId, connection);
           });
       });


The service is also in the same solution and I have it running as a console app for testing purposes. Any help is very much apreciated guys.
Posted
Comments
Francisco T. Chavez 16-May-13 2:16am    
What's the client running on? I've noticed that the done part of start().done(...) doesn't get called when I use .Net forms web site.

Also, where's the code for the hub, so that we can see if you called the correct Hub when you set the hub variable.

Also, have you checked to make sure that javascript is enabled in your browser?

Sorry if I'm all over the place, but it's a bit hard to narrow down on the problem without any details.
frostcox 16-May-13 15:51pm    
Hey, thanks for your reply, the client is running on my local iis running ie9. The hub class gets called initially when I call the hub.start() method I know this because I set a breakpoint in my hub class and it gets there with no error. My only problem is connecting to my hub class instance through my service which I don't know how to do. If you could help me that would be great. And sorry yeah JavaScript is enabled:)
Francisco T. Chavez 27-May-13 19:48pm    
Sorry about the delay, works been got busy and this just sort of slipped my mind. I noticed you said that your service is the one having trouble connecting to the hub. My next set of questions are: where is your service running, what kind of service is it, and just to be clear, the service is trying to connect to the hub (it's not playing host to the hub)?
frostcox 31-May-13 9:19am    
Hey thanks for your reply, I got it working. I just done a bit of study and learned how it all fits together, thanks again.
onelopez 17-May-13 14:26pm    
Have you tried using DisplayMessage instead? All the samples I've seen with SignalR they all had the same matching case as the C# counterpart.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900