[英]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.