locked
Server method never called, no error RRS feed

  • Question

  • User1325410084 posted

    I have a server method self-hosted in a Windows service that I'm calling from JS through the auto generated proxy.

    Turned on logging and everything looks fine, hub connects, says it is invoking the server method, then just nothing.  No breakpoints are hit in OnConnected or in the server method itself within the service.  But, I do see a bump up in memory utilization in the service when it should be connecting.

    I'm using the latest versions,

    3.3.1    JQuery

    5.2.4    Microsoft.AspNet.Cors

    2.2.3    Microsoft.AspNet.SignalR

    4.0.0    Microsoft.Owin

    I suspect that there's something incompatible between these versions, but I have no idea what at this point.  The functions deprecated in JQuery 3 seem to have been accounted for in the SignalR JS.  Is there a highest "known to work together" version set of these?

    Thursday, March 29, 2018 6:42 PM

All replies

  • User61956409 posted

    Hi Underground,

    hub connects, says it is invoking the server method, then just nothing.

    It seems that your SignalR server is self-hosted in Windows service and access the server with a JavaScript client, if possible, please share us your relevant code. Besides, you can try to enable tracing in your JavaScript client and share the tracing logs.

    With Regards,

    Fei Han

    Friday, March 30, 2018 5:24 AM
  • User1325410084 posted

    So here is the log data below.  It gets down to the last entry where it's invoking the server method call and stops.  If I manually stop the service it complains about losing the socket of course, but I also get this in regards to the server method RegisterClient call, whether I wait 30 seconds or 3 minutes.  So it appears as though the call was just sitting there waiting on something?

    [09:39:19 GMT-0500 (Central Daylight Time)] SignalR: signalrevents.RegisterClient failed to execute. Error: Connection started reconnecting before invocation result was received.

    Log data:

    [09:28:58 GMT-0500 (Central Daylight Time)] SignalR: Auto detected cross domain url.
    jquery.signalR-2.2.3.min.js:9 [09:28:58 GMT-0500 (Central Daylight Time)] SignalR: Client subscribed to hub 'signalrevents'.
    jquery.signalR-2.2.3.min.js:9 [09:28:58 GMT-0500 (Central Daylight Time)] SignalR: Negotiating with 'http://localhost:9090/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22signalrevents%22%7D%5D'.
    favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: webSockets transport starting.
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: Connecting to websocket endpoint 'ws://localhost:9090/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken= <snip> &connectionData=%5B%7B%22name%22%3A%22signalrevents%22%7D%5D&tid=7'.
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: Websocket opened.
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: webSockets transport connected. Initiating start request.
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: The start request succeeded. Transitioning to the connected state.
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332, keep alive timeout of 20000 and disconnecting timeout of 30000
    jquery.signalR-2.2.3.min.js:9 [09:28:59 GMT-0500 (Central Daylight Time)] SignalR: Invoking signalrevents.RegisterClient

    Client code:

    <script src="Scripts/jquery-3.3.1.min.js"></script>

    <script src="Scripts/jquery.signalR-2.2.3.min.js"></script>

    <script src="http://localhost:9090/signalr/hubs"></script>



    $(function () { $.connection.hub.url = "http://localhost:9090/signalr"; hub = $.connection.SignalREvents; hub.client.eventNotify = function (eventValue) { alert("Event: " + eventValue); }; $.connection.hub.error(function (error) { alert("Event service error: " + error); }); $.connection.hub.disconnected(function () { if ($.connection.hub.lastError) { alert("Disconnected reason: " + $.connection.hub.lastError.message); } else { alert("Disconnected, no error"); } }); $.connection.hub.logging = true; var test; $.connection.hub.start({ transport: ['webSockets', 'longPolling'] }) .done(function () { hub.server.RegisterClient(application) .fail(function (err) { alert("RegisterClient failed: " + err); }); }) .fail(function (err) { clientError("Could not register client: " + err); }); });

    Server method:

        [HubName("SignalREvents")]
        public class SignalREvents : Hub
        {
            
            public override Task OnConnected()
            {
                return base.OnConnected();
            }
    
            
            public override Task OnDisconnected(bool stopCalled)
            {
                return base.OnDisconnected(stopCalled);
            }
    
    
            [HubMethodName("RegisterClient")]
            public void RegisterClient(string applicationName)
            {
    
            }
    
        }

    Server configuration:

    public void Configuration(IAppBuilder app)
            {
                app.UseCors(CorsOptions.AllowAll);
    
                app.MapSignalR();
            }

    Friday, March 30, 2018 3:00 PM
  • User1325410084 posted

    I think it could be something to do with the environment.  I had code today that was working one minute, and the next it can't connect to the hub.

    Suspect an issue with websockets, we're on AWS, but I'm not sure what might be causing the problem.

    Tuesday, April 3, 2018 10:04 PM