SignalR / SignalR

Incredibly simple real-time web for .NET
http://signalr.net
Other
9.2k stars 2.28k forks source link

No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization. #3148

Closed Mds92 closed 6 years ago

Mds92 commented 10 years ago

I'm using MVC5 and SignalR 2.1.0 & Chrome 36 The following is my javascript code in webpage:

        $.connection.hub.logging = true;
        $.connection.hub.error(function (error) {
            console.log('SignalR Error: ' + error);
        });

        $.connection.hub.start().done(function () {
            alert('connected');
        });

The following is auto generated script by ASP.NET & SignalR

/*!
 * ASP.NET SignalR JavaScript Library v2.1.0
 * http://signalr.net/
 *
 * Copyright Microsoft Open Technologies, Inc. All rights reserved.
 * Licensed under the Apache 2.0
 * https://github.com/SignalR/SignalR/blob/master/LICENSE.md
 *
 */

/// 
/// 
(function ($, window, undefined) {
    /// 
    "use strict";

    if (typeof ($.signalR) !== "function") {
        throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
    }

    var signalR = $.signalR;

    function makeProxyCallback(hub, callback) {
        return function () {
            // Call the client hub method
            callback.apply(hub, $.makeArray(arguments));
        };
    }

    function registerHubProxies(instance, shouldSubscribe) {
        var key, hub, memberKey, memberValue, subscriptionMethod;

        for (key in instance) {
            if (instance.hasOwnProperty(key)) {
                hub = instance[key];

                if (!(hub.hubName)) {
                    // Not a client hub
                    continue;
                }

                if (shouldSubscribe) {
                    // We want to subscribe to the hub events
                    subscriptionMethod = hub.on;
                } else {
                    // We want to unsubscribe from the hub events
                    subscriptionMethod = hub.off;
                }

                // Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
                for (memberKey in hub.client) {
                    if (hub.client.hasOwnProperty(memberKey)) {
                        memberValue = hub.client[memberKey];

                        if (!$.isFunction(memberValue)) {
                            // Not a client hub function
                            continue;
                        }

                        subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
                    }
                }
            }
        }
    }

    $.hubConnection.prototype.createHubProxies = function () {
        var proxies = {};
        this.starting(function () {
            // Register the hub proxies as subscribed
            // (instance, shouldSubscribe)
            registerHubProxies(proxies, true);

            this._registerSubscribedHubs();
        }).disconnected(function () {
            // Unsubscribe all hub proxies when we "disconnect".  This is to ensure that we do not re-add functional call backs.
            // (instance, shouldSubscribe)
            registerHubProxies(proxies, false);
        });

        proxies['baseHub'] = this.createHubProxy('baseHub'); 
        proxies['baseHub'].client = { };
        proxies['baseHub'].server = {
        };

        proxies['fileDownloaderHub'] = this.createHubProxy('fileDownloaderHub'); 
        proxies['fileDownloaderHub'].client = { };
        proxies['fileDownloaderHub'].server = {
            getFileFromWeb: function (fileUrl, deviceId, wikiId, contentId, proxy) {
                return proxies['fileDownloaderHub'].invoke.apply(proxies['fileDownloaderHub'], $.merge(["GetFileFromWeb"], $.makeArray(arguments)));
             }
        };

        proxies['leecherHub'] = this.createHubProxy('leecherHub'); 
        proxies['leecherHub'].client = { };
        proxies['leecherHub'].server = {
            getDevice: function (devicePageUrl, proxy, leechingImages) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["GetDevice"], $.makeArray(arguments)));
             },

            getDevices: function (manufacturerName, fromPage, toPage, leechingImages, proxy) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["GetDevices"], $.makeArray(arguments)));
             },

            getManufacturers: function (proxy) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["GetManufacturers"], $.makeArray(arguments)));
             },

            setDevice: function (relativeXmlPath, submitImages) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["SetDevice"], $.makeArray(arguments)));
             },

            setDevices: function (relativeXmlPath, submitImages) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["SetDevices"], $.makeArray(arguments)));
             },

            setManufacturers: function (relativeXmlPath) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["SetManufacturers"], $.makeArray(arguments)));
             },

            testProxy: function (fileUrl, proxy) {
                return proxies['leecherHub'].invoke.apply(proxies['leecherHub'], $.merge(["TestProxy"], $.makeArray(arguments)));
             }
        };

        proxies['performanceHub'] = this.createHubProxy('performanceHub'); 
        proxies['performanceHub'].client = { };
        proxies['performanceHub'].server = {
            getData: function () {
                return proxies['performanceHub'].invoke.apply(proxies['performanceHub'], $.merge(["GetData"], $.makeArray(arguments)));
             }
        };

        return proxies;
    };

    signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });
    $.extend(signalR, signalR.hub.createHubProxies());

}(window.jQuery, window));

It worked before, and now work sometimes, but most of the times the following error concurred:

No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization. 

The following is SignalR log:

[10:12:23 GMT+0330 (Iran Standard Time)] SignalR: Client subscribed to hub 'leecherhub'. jquery.signalR-2.1.0.js:81
[10:12:23 GMT+0330 (Iran Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.4&connectionData=%5B%7B%22name%22%3A%22leecherhub%22%7D%5D'. jquery.signalR-2.1.0.js:81
[10:12:23 GMT+0330 (Iran Standard Time)] SignalR: Connecting to websocket endpoint 'ws://localhost:1758/signalr/connect?transport=webSockets&clientProtocol=1.4&connectionToken=Jkvy8rbNQEjgC1pOYdntnedTm2%2BqjlMz9s6Nqt7pgII8J32kePObvocylcBELeYQPvWK3C%2FvXsuwyHMHqgzUaekhXYIH4C%2B0dDD5lAaWcwUYqskGfKJelfx4N3JeyMJ8&connectionData=%5B%7B%22name%22%3A%22leecherhub%22%7D%5D&tid=5'. jquery.signalR-2.1.0.js:81
[10:12:23 GMT+0330 (Iran Standard Time)] SignalR: Websocket opened. jquery.signalR-2.1.0.js:81
[10:12:28 GMT+0330 (Iran Standard Time)] SignalR: webSockets timed out when trying to connect. jquery.signalR-2.1.0.js:81
[10:12:28 GMT+0330 (Iran Standard Time)] SignalR: Closing the Websocket. jquery.signalR-2.1.0.js:81
[10:12:28 GMT+0330 (Iran Standard Time)] SignalR: Attempting to connect to SSE endpoint 'http://localhost:1758/signalr/connect?transport=serverSentEvents&clientProt…fx4N3JeyMJ8&connectionData=%5B%7B%22name%22%3A%22leecherhub%22%7D%5D&tid=3'. jquery.signalR-2.1.0.js:81
[10:12:28 GMT+0330 (Iran Standard Time)] SignalR: EventSource connected. jquery.signalR-2.1.0.js:81
[10:12:33 GMT+0330 (Iran Standard Time)] SignalR: serverSentEvents timed out when trying to connect. jquery.signalR-2.1.0.js:81
[10:12:33 GMT+0330 (Iran Standard Time)] SignalR: EventSource calling close(). jquery.signalR-2.1.0.js:81
[10:12:33 GMT+0330 (Iran Standard Time)] SignalR: This browser supports SSE, skipping Forever Frame. jquery.signalR-2.1.0.js:81
[10:12:34 GMT+0330 (Iran Standard Time)] SignalR: Opening long polling request to 'http://localhost:1758/signalr/connect?transport=longPolling&clientProtocol=…fx4N3JeyMJ8&connectionData=%5B%7B%22name%22%3A%22leecherhub%22%7D%5D&tid=2'. jquery.signalR-2.1.0.js:81
[10:12:34 GMT+0330 (Iran Standard Time)] SignalR: Long poll complete. jquery.signalR-2.1.0.js:81
[10:12:34 GMT+0330 (Iran Standard Time)] SignalR: Opening long polling request to 'http://localhost:1758/signalr/poll?transport=longPolling&messageId=d-5F1D51…fx4N3JeyMJ8&connectionData=%5B%7B%22name%22%3A%22leecherhub%22%7D%5D&tid=4'. jquery.signalR-2.1.0.js:81
[10:12:39 GMT+0330 (Iran Standard Time)] SignalR: longPolling timed out when trying to connect. jquery.signalR-2.1.0.js:81
[10:12:39 GMT+0330 (Iran Standard Time)] SignalR: Aborted xhr request. jquery.signalR-2.1.0.js:81
SignalR Error: Error: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization. Device:337
[10:12:39 GMT+0330 (Iran Standard Time)] SignalR: Stopping connection. jquery.signalR-2.1.0.js:81
[10:12:39 GMT+0330 (Iran Standard Time)] SignalR: Fired ajax abort async = true. 
garysharp commented 10 years ago

Do you declare Application_PreSendRequestHeaders in your Global.asax.cs file?

See: http://forums.asp.net/t/1993105.aspx

Mds92 commented 10 years ago

No, I don't

chrisaut commented 10 years ago

I am experiencing the same issue after upgrading from 2.0.3 to 2.1. Like Mds92 I also do not have Application_PreSendRequestHeaders (only Application_Start and Application_Error).

I added server side tracing as described here, but unfortunately the transport.log files that were created did't contain any useful errors. Client side logging with DetailedErrorPolicy on just says that no transports could be initialized (all timed out).

When this occurs OnConnected is successfully called on the server (breakpoints are hit), which completes without throwing, but this is immediately followed by OnDisconnected. This happens for every transport it tries.

I have downgraded back to 2.0.3 in the meantime, everything is working perfectly again.

GliterZhang commented 10 years ago

updated to 2.1.1,this issue fixed

DamianEdwards commented 10 years ago

This sounds very much like the Application_PreSendRequestHeaders issue. Note it can be added by other modules in your application even if you don't use it directly, e.g. Glimpse, Elmah. Please try upgrading to 2.1.1 to see if it fixes the issue for you.

chrisaut commented 10 years ago

Sorry I didn't see the comment by GliterZhang earlier. I just updated.

It's fixed for me too after upgrading to 2.1.1

niemyjski commented 9 years ago

I'm still running into this issue in 2.2. I have over 2.5 million of these errors (yes million). Any ideas on what is causing this? Chrome 43 and firefox 39 if that matters.

Upon looking at the logs. I get 69k Error: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization. from a single user over the course of a few hours. But I know they were connected cause I forced a refresh for their account and I got a WebSocket closed.

image

Application source: https://github.com/exceptionless/Exceptionless

mortenalbring commented 9 years ago

Yeah I'm having this issue as well. I'm not specifying any transport and it still often says

Error: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization

However, sometimes it doesn't, and I can't at all figure out why it happens sometimes and why it doesn't happen other times.

niemyjski commented 9 years ago

@mortenalbring Yep, we aren't specifying a transport either.. https://github.com/exceptionless/Exceptionless/search?utf8=%E2%9C%93&q=signalr

mortenalbring commented 9 years ago

@niemyjski For what it's worth, it seems only to happen to me when my web application is running locally. When it's published to Azure, it doesn't seem to happen. It's still quite a nuisance when trying to debug things.

niemyjski commented 9 years ago

@mortenalbring we've only seen this when we are deployed in Azure :\

durjanh commented 9 years ago

@niemyjski do you have the fixed for Azure?

vikpai commented 9 years ago

I have a similar issue too. It seems to occur on IE 9. I cannot reproduce it locally but I can when it gets deployed. I am using signalr 2.2. Any thoughts? I did try increasing the TransportConnectTimeout timeout, but that didnt fix it for me as well.

Thanks VIkram

ghost commented 9 years ago

I also have the same error too. my signalr version is 2.2.0 and Jquery version is 2.1.4. Because This project is our first try to use signalr to implement real-time. so we don't have suffice knowledge to fix this kind of issues

Robert-Sun commented 9 years ago

Anyone please help

garysharp commented 9 years ago

@BraveIT & @Robert-Sun You've provided very little information here about your project/s and scenarios. Consider running through the troubleshooting steps found on the asp.net/signalr website: http://www.asp.net/signalr/overview/testing-and-debugging/troubleshooting Also, add JavaScript tracing to get more insight into what's happening: http://www.asp.net/signalr/overview/testing-and-debugging/enabling-signalr-tracing#javascript If you still haven't resolved the issue, consider providing specific information about your project, diagnostic information (traces), hosting information, and anything else you feel might be relevant.

ghost commented 9 years ago

@garysharp Thanks for you help about this issue there is the detailed info [13:57:35 GMT+0800 (China Standard Time)] SignalR: Client subscribed to hub 'checkin'. jquery.signalR-2.2.0.min.js:8 [13:57:35 GMT+0800 (China Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22checkin%22%7D%5D'. jquery.signalR-2.2.0.min.js:8 [13:57:35 GMT+0800 (China Standard Time)] SignalR: webSockets transport starting. jquery.signalR-2.2.0.min.js:8 [13:57:35 GMT+0800 (China Standard Time)] SignalR: Connecting to websocket endpoint 'wss://f1data.qa.fellowshipone.com/signalr/connect?transport=webSockets&clie…33N5QviXjIeBT0&connectionData=%5B%7B%22name%22%3A%22checkin%22%7D%5D&tid=2'. jquery.signalR-2.2.0.min.js:8 [13:57:36 GMT+0800 (China Standard Time)] SignalR: Websocket opened. jquery.signalR-2.2.0.min.js:8 [13:57:40 GMT+0800 (China Standard Time)] SignalR: webSockets transport timed out when trying to connect. jquery.signalR-2.2.0.min.js:8 [13:57:40 GMT+0800 (China Standard Time)] SignalR: Closing the Websocket. jquery.signalR-2.2.0.min.js:8 [13:57:40 GMT+0800 (China Standard Time)] SignalR: webSockets transport failed to connect. Attempting to fall back. jquery.signalR-2.2.0.min.js:8 [13:57:40 GMT+0800 (China Standard Time)] SignalR: serverSentEvents transport starting. jquery.signalR-2.2.0.min.js:8 [13:57:40 GMT+0800 (China Standard Time)] SignalR: Attempting to connect to SSE endpoint 'https://f1data.qa.fellowshipone.com/signalr/connect?transport=serverSentEve…33N5QviXjIeBT0&connectionData=%5B%7B%22name%22%3A%22checkin%22%7D%5D&tid=6'. jquery.signalR-2.2.0.min.js:8 [13:57:40 GMT+0800 (China Standard Time)] SignalR: EventSource connected. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: serverSentEvents transport timed out when trying to connect. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: EventSource calling close(). jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: serverSentEvents transport failed to connect. Attempting to fall back. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: foreverFrame transport starting. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: Forever Frame is not supported by SignalR on browsers with SSE support. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: foreverFrame transport failed to connect. Attempting to fall back. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: longPolling transport starting. jquery.signalR-2.2.0.min.js:8 [13:57:45 GMT+0800 (China Standard Time)] SignalR: Opening long polling request to 'https://f1data.qa.fellowshipone.com/signalr/connect?transport=longPolling&c…hRA94K33N5QviXjIeBT0&connectionData=%5B%7B%22name%22%3A%22checkin%22%7D%5D'. jquery.signalR-2.2.0.min.js:8 [13:57:50 GMT+0800 (China Standard Time)] SignalR: longPolling transport timed out when trying to connect. jquery.signalR-2.2.0.min.js:8 [13:57:50 GMT+0800 (China Standard Time)] SignalR: Aborted xhr request. jquery.signalR-2.2.0.min.js:8 [13:57:50 GMT+0800 (China Standard Time)] SignalR: longPolling transport failed to connect. Attempting to fall back. jquery.signalR-2.2.0.min.js:8 [13:57:50 GMT+0800 (China Standard Time)] SignalR: Fallback transports exhausted. index.html:515 SignalR Connecting: Error: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization. jquery.signalR-2.2.0.min.js:8 [13:57:50 GMT+0800 (China Standard Time)] SignalR: Stopping connection. jquery.signalR-2.2.0.min.js:8 [13:57:50 GMT+0800 (China Standard Time)] SignalR: Fired ajax abort async = true.

ghost commented 9 years ago

About this problem, it's very unstable, sometimes it won't show up. but sometime, it's show up again and again. it's very weird, seems this issue has been fixed after the 2.1.1. but now I use the latest version, namely 2.2.0. there still exist this kind of issue.

I also longed the TransportTimeOut time from default 5 seconds to 15 seconds. Now I am building and deploy it to our server to have a test

radu-matei commented 9 years ago

@BraveIT Any developments on this issue? I am experiencing the same issue with SignalR Redis backplane using Autofac as dependency resolver. The issue only appears once I use resolver.UseRedis();

I have setup a side project where I use basic SignalR and Autofac and I introduced the Redis scaleout. Strangely, in this project it works without any issues.

Basically, this is the same code, in the same order. (the only difference is that in the project where it doesn't work I have also WebAPI. https://github.com/radu-matei/SignalRDependencyInjection

Any development in this issue would be great.

Thanks!

niemyjski commented 9 years ago

+1

radu-matei commented 9 years ago

@niemyjski, @BraveIT Make sure that your packages are up-to-date. For example, I am using Autoafac and WebAPI and my Autofac.WebApi2 integration was not up-to-date. Simply updating this package made the connection issues go away. Hope this helps!

niemyjski commented 9 years ago

I'm running all the latest packages.

Thanks -Blake Niemyjski

On Mon, Sep 21, 2015 at 11:20 AM, Radu Matei notifications@github.com wrote:

@niemyjski https://github.com/niemyjski, @BraveIT https://github.com/BraveIT Make sure that your packages are up-to-date. For example, I am using Autoafac and WebAPI and my Autofac.WebApi2 integration was not up-to-date. Simply updating this package made the connection issues go away. Hope this helps!

— Reply to this email directly or view it on GitHub https://github.com/SignalR/SignalR/issues/3148#issuecomment-142032676.

radu-matei commented 9 years ago

Do you install StackExchange.Redis.StrongName as a dependency when installing Microsoft.AspNet.SignalR.Redis? I found that when I don't install this, this behavior appears. Best of luck. (and the application continues to work even after I uninstall it - I can't keep it since I have StackExchange.Redis already as a library and keeping them both causes conflicts).

niemyjski commented 9 years ago

Yes

radu-matei commented 9 years ago

Also, make sure that the Redis instance you are using is not part of a cluster, since it wil bounce messages from one instance to the other (using a cluster for pub/sub also caused me some tens of thousands of errors)

erico64 commented 9 years ago

Experiencing the same issue with a new JavaScript client app. and SignalR 2.2. Happens whether or not a transport protocol is specified

Dakoina commented 9 years ago

Experiencing the same issue with version 2.2.0 now. Previously I experienced less problems with version 2.0.0. Now the production server is completely useless. All connections to the clients get dropped after one or more hours, resulting in the same error.

Did v2.1.1 help for you or not? Might downgrade perhaps those libs

erico64 commented 9 years ago

In my case, it turned out to be an oversight, albeit, not a very straight forward oversight.
In my server initialization code, I specified a SQL connection string, in order to use MS SQL as my backplane. The problem was, I forgot to create the database specified in my connection string. Once I created the backplane database, no more errors. I thought I would have seen some kind of error in my server code but that wasn't the case.

cjprieb commented 8 years ago

I had this same issue using version 2.2 where it would fail with the error "No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization."

I found a StackExchange question (http://stackoverflow.com/questions/19848605/signalr-2-long-polling-protocol-request-actually-times-out-when-not-ran-locall) which was able to help me resolve the issue by increasing the timeout in both the JavaScript: $.connection.hub.transportConnectTimeout = 3000; and in my C# startup code: GlobalHost.Configuration.TransportConnectTimeout = TimeSpan.FromSeconds(10);

I haven't experimented yet to see how short of a timeout I need or whether both timeouts are needed.

SwintDC commented 8 years ago

I have the same issue with version 2.2.0. I have tried the fixes from @cjprieb without succes.

netsrotr commented 8 years ago

Long time I belived the error I got was somehow related to SignalR, but finally it was caused by the "browserlink" "feature" in newer versions of VS.IDE (2015 in my case). If you test outside your IDE calling your web app and the error is gone, it is very likely an issue with "browserlink". To disable / enable browserlink, see Using Browser Link in Visual Studio 2013.

elgerm commented 7 years ago

I can reproduce this error by turning on redis scaleout in the startup of the signalr server (v2.2.2). When turned on, no transport can be initialized. I'm using the following code:

RedisScaleoutConfiguration config = new RedisScaleoutConfiguration(ConfigurationManager.ConnectionStrings["RedisConnectionString"].ConnectionString, "website"); GlobalHost.DependencyResolver.UseRedis(config);

The connectionstring looks like this:

<add name="RedisConnectionString" connectionString="localhost:6379,ssl=False,abortConnect=False,connectTimeout=30000,SyncTimeout=15000"/>

I'm using Stackexchange.Redis.Strongname v 1.2.3

It's odd, because this exact same configuration did work on azure. We recently moved from azure to a VPS, with windows server 2016.

moozzyk commented 7 years ago

@elgerm - Are you sure SignalR is able to connect to Redis? I did run SignalR with Redis Scalout both locally and on Azure and did not encounter this problem.

elgerm commented 7 years ago

@moozzyk Locally and azure yes, it works, but not on the VPS running 2016. I'll investigate further this weekend, the connectionstring I mentioned above is the same for redis caching in the API (stackexchange.redis) as for scaling out, I can confirm Redis is working fine with web API on the VPS, only signalr stops working when I uncomment the config section.

Andrey2G commented 7 years ago

I'm getting the same issue in 2.2.2 (and it appears randomly), but everything was working perfectly during at least last 3 years before I implemented Scaleout with Redis I added the latest NuGet package Microsoft.AspNet.SignalR.Redis with StackExchange.Redis.StrongName (1.1.608) And setup it in the same order as described here But in my case Redis is standalone on Linux (not in Azure), website with SignalR on Widnows Server 2012 The issue appears randomly

FabioGCMagalhaes commented 6 years ago

+1 on 2.2.2

00:00:31.8838066 - XXXX - WS Connecting to: ws://localhost:8000/signalr/connect?clientProtocol=1.4&transport=webSockets&connectionData=[{"Name":"eventNotificationHub"}]&connectionToken=XXXXXX

00:00:36.8940132 - XXXX - WS: OnClose()

00:00:36.8950154 - XXXX - Auto: Failed to connect to using transport webSockets. System.TimeoutException: Transport timed out trying to connect

00:00:36.8960190 - XXXX - SSE: GET http://localhost:8000/signalr/connect?clientProtocol=1.4&transport=serverSentEvents&connectionData=[{"Name":"eventNotificationHub"}]&connectionToken=XXXXXX

00:00:36.9256022 - XXXX - SSE: OnMessage(Data: initialized)

00:00:41.9074870 - XXXX - Auto: Failed to connect to using transport serverSentEvents. System.TimeoutException: Transport timed out trying to connect

00:00:41.9255364 - XXXX - LP Connect: http://localhost:8000/signalr/connect?clientProtocol=1.4&transport=longPolling&connectionData=[{"Name":"eventNotificationHub"}]&connectionToken=XXXXXX

00:00:46.9311243 - XXXX - Auto: Failed to connect to using transport longPolling. System.TimeoutException: Transport timed out trying to connect

00:00:46.9562573 - XXXX - Disconnected

00:00:46.9567600 - XXXX - Transport.Dispose(XXXX)

00:00:46.9580938 - XXXX - Closed Exception thrown: 'System.TimeoutException' in mscorlib.dll

Any help is very much appreciated.

muratg commented 6 years ago

cc @anurse

analogrelay commented 6 years ago

@FabioGCMagalhaes can you collect server-side traces using the instructions here: https://docs.microsoft.com/en-us/aspnet/signalr/overview/testing-and-debugging/enabling-signalr-tracing ? You can log traces to the Windows Event Log or to Text Files. Once you've got a trace, can you share it on this issue (preferably via a Gist to avoid a long comment here on this thread). Also, when configuring tracing, I suggest using the <sources> section from this config because it has more detailed tracing enabled: https://gist.github.com/moozzyk/5abdc2ff439c179832e143c6a72a3e0a

That will help to identify what is different about your scenario and why we can't reproduce it. Generally the error you are seeing (failing to connect any transport) happens because some error is happening on the server that isn't being exposed to the client.

FabioGCMagalhaes commented 6 years ago

@anurse Thanks for getting back to me!

I ran my server outside of the Service Fabric to be able to expose all that was going on inside and was able to figure out my problem. I was using GlobalHost.DependencyResolver.UseSqlServer(connectionString);, and connecting to a SQL Azure DB that was launching a System.PlatformNotSupportedException. Changing the DB to a non SQL Azure worked instantly.

analogrelay commented 6 years ago

Glad to hear you got it sorted out!

I'm going to close this issue as I don't see any further action items or questions here. For anyone on this thread who is still having an issue, feel free to open a new issue or comment further on this issue if you need assistance!

analogrelay commented 6 years ago

@AndreyGrunyov If you are still seeing an issue, can you collect server traces (see my comment above) and open a new issue for that? I just don't want it to get lost in this long thread :)

FloriAll commented 6 years ago

Hi Guys, some good tips in here. However, we are having this issue still and a high frequency. We are running our instance of Redis (v 4.4.2-35) and signalR (v 2.2.1). Any help on how to resolve this issue is appreciated.

SignalR Error: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.

at InitHandler.transportFailed[angular]

(anonymous) @ angular.js?3437:14195 angular.js?3437:14195 Could not Connect!

analogrelay commented 6 years ago

Have you collected the server traces I referenced above? This issue is generally masking a server-side issue that's preventing the transports from initializing, thus causing the client to fail to find a working transport.

FloriAll commented 6 years ago

Thank you @anurse ! We are enabling the traces tonight and will send it in the morning.

FloriAll commented 6 years ago

@anurse Here is what we see in the logs:

"_index": "cwl-2018.02.12", "_type": "prod2", "_id": "33862482539801661846243226071627628985197178478719664128", "_version": 1, "_score": null, "_source": { "Message": "OnError(a4f23c26-c11b-4a4c-8804-c74e67e73c9c, System.Net.WebSockets.WebSocketException (0x80070026): Reached the end of the file\r\n at System.Web.WebSockets.WebSocketPipe.<>cDisplayClass9_0.b0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.WebSockets.AspNetWebSocket.d45`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass36_0.<b0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.d3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.d25.MoveNext())", "EventLog": "Application", "EventID": 0, "Application": "SignalRTransportLog", "LogLevel": "Error", "Source": "API03.prod2.dealer-fx.com", "@id": "33862482539801661846243226071627628985197178478719664128", "@timestamp": "2018-02-12T14:37:13.000Z", "@message": "[Application] [Error] [0] [SignalRTransportLog] [API03.prod2.dealer-fx.com] [OnError(a4f23c26-c11b-4a4c-8804-c74e67e73c9c, System.Net.WebSockets.WebSocketException (0x80070026): Reached the end of the file\r\n at System.Web.WebSockets.WebSocketPipe.<>cDisplayClass9_0.b0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.WebSockets.AspNetWebSocket.d45`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass36_0.<b0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.d3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.d25.MoveNext())]", "@owner": "477751613945", "@log_group": "prod2", "@log_stream": "API03" }, "fields": { "@timestamp": [ "2018-02-12T14:37:13.000Z" ] }, "sort": [ 1518446233000 ] }

FloriAll commented 6 years ago

More captures of the error SignalR.txt

FloriAll commented 6 years ago

Good morning @anurse! Did you have a chance to review the trace? Is the information provided enough to do a first analysis? Thanks in advance for your help.

analogrelay commented 6 years ago

This is an error that occurs external to SignalR. Something is terminating the underlying TCP connection out from under the WebSocket, hence the "end-of-file" error. As an example, see https://github.com/SignalR/SignalR/issues/3823 (though it could be something else causing the issue on your machine).

FloriAll commented 6 years ago

Thanks @anurse . Appreciate your feedback. I looked at the example and confirmed that we do not run \ have a firewall. Will do some more digging.

riast commented 6 years ago

If you are using react or react-native, being connected to chrome-debugger can cause this issue as well!