当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net mvc - Can't get transports in SignalR

问题描述:

When I run $.connection.hub.start() I get these errors from "resources" (I traced it).

These are the errors i'm getting

errorOnNegotiate -> "Error during negotiation request.".

errorParsingNegotiateResponse -> "Error parsing negotiate response.".

errorSourceError -> "Error raised by EventSource".

eventSourceFailedToConnect -> "EventSource failed to connect.".

longPollFailed -> "Long polling request failed.".

noConnectionTransport -> "Connection is in an invalid state, there is

no transport active.". nojQuery -> "jQuery was not found. Please

ensure jQuery is referenced before the SignalR client JavaScript

file.". noTransportOnInit -> "No transport could be initialized

successfully. Try specifying a different transport or none at all for

auto initialization.".

网友答案:

Part of the error is this : "jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.""

you need to add jQuery reference this can be done like so (Please note that in this sample the signalR version is 2.0.2 you need to add the correct reference to the version you are using):

 <!--Reference the jQuery library. -->
 <script src="Scripts/jquery-1.6.4.min.js"></script>
 <!--Reference the SignalR library. -->
 <script src="Scripts/jquery.signalR-2.0.2.min.js"></script>
网友答案:

It looks like you've pasted the contents of the resources object within signalR._.error(). That object contains a list of possible errors, not the error your're getting. For example, here it's being used to get the error message when the negotiation response couldn't be parsed:

try {
                        res = connection._parseResponse(result);
                    } catch (error) {
                        onFailed(signalR._.error(resources.errorParsingNegotiateResponse, error), connection);
                        return;
                    }
分享给朋友:
您可能感兴趣的文章:
随机阅读: