android signalR hubconnection 应用程序与服务器协商失败

android signalR hubconnection application negotiation failed with server

嗨,我是 android 开发新手,我想编写一个使用 signalR java-客户端的应用程序。在第一步中,我做了 this 的答案,这是我的客户端代码:

Platform.loadPlatformComponent(new AndroidPlatformComponent());
String host = "localhost";
HubConnection connection = new HubConnection( host);
HubProxy hub = connection.createHubProxy("HubConnectionAPI");

SignalRFuture<Void> awaitConnection = connection.start(new LongPollingTransport(connection.getLogger()));
try {
    awaitConnection.get();
} catch (InterruptedException e) {
    e.printStackTrace();
} catch (ExecutionException e) {
    e.printStackTrace();
}

hub.subscribe(this);
try {
    hub.invoke("DisplayMessageAll", "message from android client").get();
    System.out.println("sent!!!");
} catch (InterruptedException e) {
    e.printStackTrace();
} catch (ExecutionException e) {
    e.printStackTrace();
}

您可以从 here

下载服务器代码

我有以下错误 awaitConnection.get();

错误:

W/System.err: java.util.concurrent.ExecutionException: microsoft.aspnet.signalr.client.transport.NegotiationException: There was a problem in the negotiation with the server

我也有这个错误:

Caused by: microsoft.aspnet.signalr.client.http.InvalidHttpStatusCodeException:Invalid status code: 404

谁能帮帮我?我搜索了很多,但没有找到对我有帮助的东西

编辑:

客户端可以通过 this 访问集线器,但我如何在 android 上实施以便我的应用程序可以连接?

这是服务器上的日志文件:

2015-11-11 09:05:08 10.2.0.18 GET /signalr/negotiate clientProtocol=1.3&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D 80 - 10.2.0.253 SignalR+(lang=Java;+os=android;+version=2.0) - 404 0 2 3

更改了 String host = "localhost";

String host = "localhost/signalr";

localhost 对我不起作用,我必须在 IIS 上部署 asp.net 网络应用程序,允许防火墙入站规则中的端口并将其放入 android 的 signalr 配置中。希望这对某人有帮助...干杯!