0
votes

I have a SignalR app and a console application.

I run my SignalR app on IIS.

I have a console application that connects, and should print out some pretty basic messages when receiving a response.

Locally, this all works fine.

When I publish the SignalR app to my dev. box, I suddenly am unable to recieve messages back from the hub.

My console app invokes the hub method "CaptureComplete"

        //notify that a specific camera has completed a capture
        public void CaptureComplete(string captureId)
        {
            var g = Guid.NewGuid();
            Clients.All.cameraCaptureCompleteEvent(g.ToString());
        }

The above method should return a GUID as a string to my console app.

My console app, although connected to SignalR hub, receives a null response.

enter image description here

Am I missing something obvious? Why does this work locally, but not in dev/hosted environment?

1

1 Answers

0
votes

CaptureComplete is a void method so it does not return any result and therefore task.Result is null. If your CaptureComplete returned a value you would be able to get the value using task.Result. The string you are broadcasting to clients with Clients.All.cameraCaptureCompleteEvent(g.ToString()); will be available in the callback to the cameraCaptureCompleteEvent client side method. To subscribe to this callback you need to call:

myHub.On<string>("cameraCaptureCompleteEvent", s => Console.WriteLine);