Ich habe Probleme beim Verbinden meiner Java-Anwendung mit meinem SignalR Server.
Der Server ist sehr einfach und kann hier bestellt werden:.
https://code.msdn.microsoft.com/windowsdesktop/Using-SignalR-in-WinForms-f1ec847bSignalR Java kann keine Verbindung zum Server herstellen
ich Web-Clients (Javascript) und Windows-Clients (C#) aber ich habe mit meinem Java-Client Probleme verbinden kann (https://github.com/SignalR/java-client)
Hier ist mein Code so weit:
package javaapplication2;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import microsoft.aspnet.signalr.client.SignalRFuture;
import microsoft.aspnet.signalr.client.hubs.HubConnection;
import microsoft.aspnet.signalr.client.hubs.HubProxy;
public class JavaApplication2 {
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException, TimeoutException
{
String ServerURI = "http://localhost:8080/signalr";
HubConnection Connection = new HubConnection(ServerURI);
HubProxy HubProxy = Connection.createHubProxy("MyHub");
HubProxy.on("AddMessage",() -> { System.out.println("Some message"); });
Connection.error(new ErrorCallback() {
@Override
public void onError(Throwable error) {
error.printStackTrace(); //<==SocketException
}
});
SignalRFuture<Void> con =Connection.start();
con.get();
}
}
aktualisieren
Wenn ich es laufen erhalte ich eine „ExecutionException: java.net.SocketException: Anschluss Reset“
Exception in thread "main" java.util.concurrent.ExecutionException: java.net.SocketException: Connection reset
at microsoft.aspnet.signalr.client.SignalRFuture.get(SignalRFuture.java:112)
at microsoft.aspnet.signalr.client.SignalRFuture.get(SignalRFuture.java:102)
at javaapplication2.JavaApplication2.main(JavaApplication2.java:27)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:675)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1535)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:72)
at java.lang.Thread.run(Thread.java:745)
-Wenn ich „localhost“, um etwas zu ändern, die nicht (zB locahostX) Ich habe ein Java existiert bekommen .net.UnknownHostException
-Wenn Wenn ändern „localhost“ auf meine IP-I-Ereignis keine Ausnahme erhalten ...
-Alle anderen Anwendungen arbeiten sowohl mit (localhost oder IP)
Zuerst dachte ich, es wäre ein Firewall-Problem, aber es war nicht das ...
Offensichtlich vermisse ich etwas ... Irgendwelche Ideen?
Dank
Nicht sicher über das Problem, aber haben Sie versucht, HubConnection-Konstruktor-Überladung, die ILogger-Instanz verwendet verwenden?Es scheint, als ob die automatische Transportauswahl (Verhandlung) nicht funktioniert und das interne SignalR-Protokoll könnte hier hilfreich sein. Probieren Sie es aus und veröffentlichen Sie das Protokoll ... –