Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8872531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:14:32+00:00 2026-06-14T18:14:32+00:00

I have a simple SignalR hub application, using MVC4/C# on the server end, hosted

  • 0

I have a simple SignalR hub application, using MVC4/C# on the server end, hosted in an Azure Web Role (single instance, in the emulator, with an http input endpoint), and TypeScript compiled to JS on the client. I have a gallery of images that a number of clients may upload to, and when somebody uploads then I want any other connected clients to receive a message telling them this has happened and giving them the chance to refresh, similar to the way you are notified about a new answer to a question you are viewing here on SO.

On the server I have a method which returns a list of the items in the gallery, and another method to push messages to clients, like this:

    public virtual void PushMessage(String message)
    {
        System.Diagnostics.Debug.WriteLine("PushMessage: " + message);
        this.Clients.All.pushMessage(message);
    }

    public virtual GalleryDataResponse<T> List(String accountID, String armID, Int32 page)
    {
        GalleryDataResponse<T> response = new GalleryDataResponse<T>();
        try
        {
            IEnumerable<T> items = getAllItems(accountID, armID, page);
            if (items != null && items.Count() > 0)
            {
                response.Result = DataResponse.RESULT_DATA;
                response.Message = String.Empty;
                response.Items = items;
            }
            else
            {
                response.Result = DataResponse.RESULT_EMPTY;
                response.Message = @"There are no " + itemName + @"s in your account at the moment: " + this.Context.ConnectionId;
                response.Items = null;
            }
            this.Caller.pushMesage("HELLO, CALLER");
            PushMessage("HELLO, ALL CLIENTS");
        }
        catch (Exception ex)
        {
            response.Result = DataResponse.RESULT_ERROR;
            response.Message = ex.Message;
            response.Items = null;
        }
        return response;
    }

(The List function is then overridden in a derived class which passes in the type T – this works fine).

On the client, using the SignalR definition files from DefinitelyTyped I have the following TypeScript:

var that = this;
this.connection = $.hubConnection();
this.connection.logging = true;
this.connection.id = this.gServerData.CurrentAccountID + "-" +    this.gServerData.CurrentArmID;
this.connection.start().done(() => {
    that.proxy = that.connection.createProxy(that.gServerData.DataHubName);
    that.proxy.on("pushMessage", (message) => {
        console.log("PUSHED: " + message);
        debugger;
    });
    that.proxy.invoke("List", that.gServerData.CurrentAccountID, that.gServerData.CurrentArmID, 0).done((response: IGalleryDataResponse) => {
        that.handleListResponse(response);
    });
});

… which gives the following JavaScript:

var that = this;
this.connection = $.hubConnection();
this.connection.logging = true;
this.connection.id = this.gServerData.CurrentAccountID + "-" + this.gServerData.CurrentArmID;
this.connection.start().done(function () {
    that.proxy = that.connection.createProxy(that.gServerData.DataHubName);
    that.proxy.on("pushMessage", function (message) {
        t.Tracer.Trace("PUSHED: " + message);
    });
    that.proxy.invoke("List", that.gServerData.CurrentAccountID, that.gServerData.CurrentArmID, 0).done(function (response) {
    that.handleListResponse(response);
    });
});

Invoking my list function works perfectly. I get a response back from the hub exactly as expected. And if I kill the server process but keep the browser alive, I get errors in the console which show me that the client is trying to maintain a connection.

I added these two lines this.Caller.pushMesage("HELLO, CALLER"); PushMessage("HELLO, ALL CLIENTS"); to my List function on the server side to test the server pushing content to the client. I’m expecting them to be called before the list function returns, but this isn’t happening. I’ve also tried calling the hub from outside, like this:

var myHub = GlobalHost.ConnectionManager.GetHubContext<MediaGalleryHub>();
myHub.Clients.pushMessage("Hello from Global.asax");

… but while I can see from tracing that my PushMessage function is being called, I never get anything on the client side.

What am I doing wrong?

References I’ve already tried include:

http://blogs.msdn.com/b/brunoterkaly/archive/2012/04/09/how-to-build-cloud-based-asynchronous-scalable-web-applications-with-near-real-time-persistent-long-running-connections-with-signalr.aspx

http://msdn.microsoft.com/en-us/magazine/hh965663.aspx

https://github.com/SignalR/SignalR/wiki/Hubs

https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client-Hubs-%28No-Proxy%29

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:14:33+00:00Added an answer on June 14, 2026 at 6:14 pm

    This part of the code is wrong:

    this.connection.start().done(() => {
        that.proxy = that.connection.createProxy(that.gServerData.DataHubName);
        that.proxy.on("pushMessage", (message) => {
            console.log("PUSHED: " + message);
            debugger;
        });
        that.proxy.invoke("List", that.gServerData.CurrentAccountID, that.gServerData.CurrentArmID, 0).done((response: IGalleryDataResponse) => {
            that.handleListResponse(response);
        });
    });
    

    You need to subscribe before you call start:

    that.proxy = that.connection.createProxy(that.gServerData.DataHubName);
    that.proxy.on("pushMessage", (message) => {
        console.log("PUSHED: " + message);
        debugger;
    });    
    
    this.connection.start().done(() => {
        that.proxy.invoke("List", that.gServerData.CurrentAccountID, that.gServerData.CurrentArmID, 0).done((response: IGalleryDataResponse) => {
            that.handleListResponse(response);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My web application have a chat app module built on SignalR hub. The app
I have simple project, where I'm using signalR, When page loads, signalR scripts are
I currently have a very simple web application written in Django, and I would
I have a simple server that looks something like this: void *run_thread(void *arg) {
very new to signalR, and have rolled up a very simple app that will
I have a pretty simple .net 4 desktop application written in c# which needs
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
I have a simple application with a manager thread that spawns ten simple worker
I have a simple TCP client which is connected to twisted using: reactor.connectTCP(host, port,
I'm new to SignalR and have done a simple test hack. I wish to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.