3
votes

I am using SignalR 2.0.0-rc1 and having some problems when deploying it to my server.

Server side I am defining a hub (I've also tried with void return type, but that was causing me an async exception: https://github.com/SignalR/SignalR/issues/656 )

public class IpnHub : Hub
{
    // This is the method that never gets called on IIS
    public async Task<bool> CheckPayKey(string payKey)
    {
        bool payKeyValid;
        // code that sets payKeyValid to true or false

        await Clients.Caller.checkPayKey((payKeyValid));
        return payKeyValid;
    }
}

I am mapping the hubs in the startup class (and added it to web.config and made sure it's being executed):

public partial class Startup 
{
    public void Configuration(IAppBuilder app) 
    {
        app.MapSignalR();
        ConfigureAuth(app);
    }
}

On my test html page, I have the following JS code:

<script type="text/javascript">
    var thisPayKey = 'thisisapaykey';
    $(function() {
        var ipnHub = $.connection.ipnHub;

        ipnHub.client.checkPayKey = function(isValid) {
            alert(isValid);
        };
        $.connection.hub.logging = true;
        $.connection.hub.start().done(function() {
            ipnHub.server.checkPayKey(thisPayKey);
        });
    });
</script>

The log says:

[03:06:25 GMT+0200 (Romance Daylight Time)] SignalR: Client subscribed to hub 'ipnhub'.
[03:06:25 GMT+0200 (Romance Daylight Time)] SignalR: Negotiating with '/signalr/negotiate?connectionData=%5B%7B%22name%22%3A%22ipnhub%22%7D%5D&clientProtocol=1.3'. 
[03:06:25 GMT+0200 (Romance Daylight Time)] SignalR: Attempting to connect to SSE endpoint 'http://bothaven.com/signalr/connect?transport=serverSentEvents&connectionTo…SqI%2B%2FXvBpv&connectionData=%5B%7B%22name%22%3A%22ipnhub%22%7D%5D&tid=10'. 
[03:06:25 GMT+0200 (Romance Daylight Time)] SignalR: EventSource connected.
[03:06:25 GMT+0200 (Romance Daylight Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332 and a connection lost timeout of 20000. 

I checked fiddler as suggested in this post: https://stackoverflow.com/a/16905370/1727447 And all of his tests return status 200.

When I run the application in Visual studio and I open the test html page - I instantly get a popup with the boolean returned from the server. Also, the following line is shown in the console log in addition to the ones above:

[03:16:04 GMT+0200 (Romance Daylight Time)] SignalR: Triggering client hub event 'checkPayKey' on hub 'IpnHub'.

I've checked - and not even the first like of the CheckPayKey method is being called server side when it's on my iis. It is iis 7.5 running on Windows Server 2008 R2 if that matters. I've been banging my head at this for many hours now, and I just can't seem to figure out what's wrong.

EDIT: For the sake of trying to locate the problem, I tried creating a new VS project and created my own little sample that I provided here - and then I created a new website on the IIS with a new application pool. When I published this to IIS - it worked. I then tried publishing the full website that uses this code to the same IIS website, and it did not work. What this tells me is that it must be a web.config problem or something with the project.

1

1 Answers

0
votes

In Windows Server 2008, in-box IIS version is 7.0, and .Net 4.5 is not in-box component, SignalR 2.0 requires .Net 4.5, so you need install .Net 4.5.

In Windows Server 2008 R2, in-box IIS version is 7.5, just wondering if your server is Windows Server 2008 R2? I tried your repro on IIS web site on Windows Server 2008 R2, it works.