I've just started using a bit of SignalR and am trying to set it up so a windows service can send messages to a web page.
I have the hub all setup and this seems to work fine within the website.
Namespace SignalR Public Class SignalRHub Inherits Hub Public Sub Send(name As String, message As String) Clients.All.broadcastMessage(name, message) End Sub End Class End Namespace
However I can't get my windows service to connect to the hub in any shape or form.
The code below correctly gets an auth token via the webservice and then makes the hub connection. However the hub connection always comes back disconnected and then the hubConnection start always throws the error "Unexpected character encountered while parsing value: . Path '', line 0, position 0."
I've tried monitoring in fiddler and nothing appears to show up for any kind of attempt at hitting the SignalR api. The hubs page is up and accessible at
http://localhost:56731/signalr/hubs
Anyone know what I'm doing wrong?
protected override void OnStart(string[] args) { Debugger.Launch(); WriteToLog("Service Started"); try { String url = "http://localhost:56731/"; var wsAuth2 = new wsAuth.Authentication(); string authToken = wsAuth2.Authenticate("username", "password"); var hubConnection = new HubConnection(url, new Dictionary<string, string> { { "token", authToken } }); IHubProxy signalRServiceProxy = hubConnection.CreateHubProxy("SignalRHub"); hubConnection.Start().Wait(); signalRServiceProxy.Invoke("Send", "Hello Billy!").Wait(); } catch (Exception ex) { var error = ex.GetError(); } }
Thanks.