简体   繁体   English

从Signalr .net客户端调用集线器方法将引发异常

[英]Invoking hub method from signalr .net client throws exception

I've been trying to call a method on my hub from a signalr .Net client however it throws the following exception: 我一直在尝试从Signalr .Net客户端在集线器上调用方法,但是它引发以下异常:

[ArgumentNullException: Value cannot be null.
Parameter name: s]
   System.IO.StringReader..ctor(String s) +10894409
   Microsoft.AspNet.SignalR.Json.JsonSerializerExtensions.Parse(JsonSerializer serializer, String json) +63
   Microsoft.AspNet.SignalR.Hubs.HubRequestParser.Parse(String data, JsonSerializer serializer) +19
   Microsoft.AspNet.SignalR.Hubs.HubDispatcher.OnReceived(IRequest request, String connectionId, String data) +40
   Microsoft.AspNet.SignalR.<>c__DisplayClassc.<ProcessRequest>b__7() +34
   Microsoft.AspNet.SignalR.TaskAsyncHelper.FromMethod(Func`1 func) +28
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
   Microsoft.AspNet.SignalR.Transports.<ProcessSendRequest>d__10.MoveNext() +364
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
   Microsoft.Owin.Mapping.<Invoke>d__0.MoveNext() +386
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +64
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +415
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

This is when I try to invoke the method on a remote host, the weird thing when developing it it actually does work locally... 这是当我尝试在远程主机上调用该方法时,在开发该方法时它确实在本地起作用的怪异事物。

Here is the code of the hub: 这是集线器的代码:

public void UpdateLocalPlayerName(string name)
{
    ...

    foreach (var connection in websiteConnections)
    {
        Clients.Client(connection.ConnectionID).UpdateLocalPlayerName(Context.ConnectionId, name);
    }
}

And here is how I try to invoke it with the .Net client 这就是我尝试使用.Net客户端调用它的方法

public void UpdateLocalPlayerName(string name)
{
    MainHubProxy.Invoke<string>("UpdateLocalPlayerName", name);
}

I am using 2.0.3.0 version of the .Net client and the server runs IIS8... 我正在使用2.0.3.0版本的.Net客户端,并且服务器运行IIS8 ...

Any idea what causes this? 知道是什么原因造成的吗?

Seems to be I had www. 好像是我有www。 infront of the server's url I was connecting to, guess the routing prevented the arguments from being passed correctly. 我正在连接的服务器url的前面,猜测路由阻止了参数的正确传递。 Changed the url to the url without www and it worked. 将该网址更改为不带www的网址,并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自客户端的集线器方法未在ASP.NET Core SignalR中调用 - Hub method from client is not invoking in ASP.NET Core SignalR 来自控制器的SignalR广播未调用客户端方法 - SignalR Broadcast from Controller Not Invoking Client Method SignalR:调用Hub方法“XXX”时出错 - SignalR: There was an error invoking Hub method “XXX” 从SignalR中的客户端调用Hub类之外的服务器方法 - Calling a server method that is outside of the Hub class from the client in SignalR 从 JavaScript 客户端调用服务器上的方法时出现 SignalR 错误 - SignalR error when invoking method on the server from JavaScript client SignalR - 用于检测客户端是否与集线器断开连接的服务器端方法? - SignalR - Server side method to detect if a client disconnects from a hub? SignalR - 从.NET客户端枚举可用的集线器和集线器方法 - SignalR - enumerate available hubs and hub methods from .NET client 无法从 JavaScript 客户端连接到 ASP.NET SignalR 集线器 - Unable to connect to ASP.NET SignalR hub from JavaScript client ASP.NET Core SignalR可从任何地方访问Hub方法 - ASP.NET Core SignalR acces Hub method from anywhere SignalR:不调用集线器中的方法以实时返回JSON - SignalR : Not invoking method in hub to return JSON in real-time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM