Giter Site home page Giter Site logo

java-client's Introduction

ASP.NET SignalR

IMPORTANT: There will be no new features added to this product. We are in maintenance mode and only fixing critical issues. See our blog post for details. This repository hosts code and project management for ASP.NET SignalR, for use in .NET Framework applications using System.Web or Katana. If you are looking for information on ASP.NET Core SignalR, see the https://github.com/aspnet/AspNetCore/tree/main/src/SignalR repository.

ASP.NET SignalR is a library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.

What can it be used for?

Pushing data from the server to the client (not just browser clients) has always been a tough problem. SignalR makes it dead easy and handles all the heavy lifting for you.

Documentation

See the documentation

Get it on NuGet!

Install-Package Microsoft.AspNet.SignalR

Get a sample on NuGet, straight into your app!

Install-Package Microsoft.AspNet.SignalR.Sample

LICENSE

Apache 2.0 License

Contributing

See the contribution guidelines

Building the source

git clone [email protected]:SignalR/SignalR.git (or https if you use https)

Windows

After cloning the repository, run build.cmd.

NOTE: Opening the solution requires VS 2017.

Questions?

java-client's People

Contributors

arnoldp-workstreampeople-com avatar eilon avatar pablozaiden avatar salmangadit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-client's Issues

Could not find org.java-websocket:java-websocket:1.3.1.

there isn't version 1.3.1.
I just find the version 1.3.0 . this is the latest version.

android studio:

Error:A problem occurred configuring project ':signalr-client-sdk-android'.

Could not resolve all dependencies for configuration ':signalr-client-sdk-android:_debugCompile'.
Could not find org.java-websocket:java-websocket:1.3.1.
Searched in the following locations:
https://jcenter.bintray.com/org/java-websocket/java-websocket/1.3.1/java-websocket-1.3.1.pom
https://jcenter.bintray.com/org/java-websocket/java-websocket/1.3.1/java-websocket-1.3.1.jar
file:/C:/Program Files (x86)/Android/android-sdk/extras/android/m2repository/org/java-websocket/java-websocket/1.3.1/java-websocket-1.3.1.pom
file:/C:/Program Files (x86)/Android/android-sdk/extras/android/m2repository/org/java-websocket/java-websocket/1.3.1/java-websocket-1.3.1.jar
file:/C:/Program Files (x86)/Android/android-sdk/extras/google/m2repository/org/java-websocket/java-websocket/1.3.1/java-websocket-1.3.1.pom
file:/C:/Program Files (x86)/Android/android-sdk/extras/google/m2repository/org/java-websocket/java-websocket/1.3.1/java-websocket-1.3.1.jar
Required by:
Test3:signalr-client-sdk-android:unspecified > Test3:signalr-client-sdk:unspecified

Is there any sample about using websocket?

I'm using in this whey:

WebsocketTransport ss = new WebsocketTransport(new Logger() {
@OverRide
public void log(String arg0, LogLevel arg1) {
Log.d("@NewLogger", arg0);
Log.d("@NewLogger", arg1.toString());
}
});

SignalRFuture startFuture = connection
.start(ss );

startFuture.get(60, TimeUnit.SECONDS);

Websockets

It would be great if websockets were supported.

Reconnect event not working!

Im starting connection, then i stop website in iis, wait for 2-3 seconds then i start again. The clients never get in recconect state. In order to reconnect i must create new instance of HubConnection.

'Disconnected' state still even though it was in the connected event

The exception:" The operation is not allowed in the 'Disconnected' state" fires even when I put the sendMessage() inside the connected event (connection.connected(Runnable with my method)). The connected method is called only when it is completely connected, right? Why this exceptions appears? Follow the logger:

Request executed
05-07 22:54:21.980 8493-8841/com.example.app D/LOG__SIGNAL﹕ serverSentEvents - Response received
05-07 22:54:21.980 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Entered startLock after transport was started
05-07 22:54:21.980 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Current state: Connecting
05-07 22:54:21.980 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Starting Heartbeat monitor
05-07 22:54:21.990 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Connected
05-07 22:54:22.885 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubProxy ChatHub - Invoking method on hub: SendMessage
05-07 22:54:22.895 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Registering callback: 0
05-07 22:54:22.960 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Sending: {"A":["1@2","Oi","1@1"],"I":"0","H":"ChatHub","M":"SendMessage"}
05-07 22:54:22.965 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Error: microsoft.aspnet.signalr.client.InvalidStateException: The operation is not allowed in the 'Disconnected' state
05-07 22:54:22.970 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubProxy ChatHub - Invoking method on hub: SendMessage
05-07 22:54:22.975 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Registering callback: 1
05-07 22:54:22.990 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Sending: {"A":["1@2","Diha","1@4"],"I":"1","H":"ChatHub","M":"SendMessage"}
05-07 22:54:22.990 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Error: microsoft.aspnet.signalr.client.InvalidStateException: The operation is not allowed in the 'Disconnected' state
05-07 22:54:22.995 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubProxy ChatHub - Invoking method on hub: SendMessage
05-07 22:54:23.005 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Registering callback: 2
05-07 22:54:23.015 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Sending: {"A":["1@2","Hhj","1@5"],"I":"2","H":"ChatHub","M":"SendMessage"}
05-07 22:54:23.015 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Error: microsoft.aspnet.signalr.client.InvalidStateException: The operation is not allowed in the 'Disconnected' state
05-07 22:54:23.020 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubProxy ChatHub - Invoking method on hub: SendMessage
05-07 22:54:23.020 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Registering callback: 3
05-07 22:54:23.030 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Sending: {"A":["1@2","Jbb","1@6"],"I":"3","H":"ChatHub","M":"SendMessage"}
05-07 22:54:23.030 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Error: microsoft.aspnet.signalr.client.InvalidStateException: The operation is not allowed in the 'Disconnected' state
05-07 22:54:23.035 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubProxy ChatHub - Invoking method on hub: SendMessage
05-07 22:54:23.035 8493-8841/com.example.app D/LOG__SIGNAL﹕ HubConnection - Registering callback: 4

Thanks.

Problem with Samsung Galaxy S3. Connection always gets slow (Slow connection detected), falls down and tries repeatedly reconnect but without success.

Always after the connection was established (around 20 seconds), it gets slow and enter in an endless looping of "reconnecting" and "reconnected" sequentially without stopping.
Before SignalR Android be released I was using SignalA (https://github.com/erizet/SignalA) this problem does not occur with SignalA ,so I tried to compare the request of both at the same server. I could notice a difference in the http header and response at the same server (Windows Server 2012 / IIS 8) :

---SignalA Header----
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J)

---SignalR Android Header---
User-Agent: SignalR (lang=Java; os=android; version=2.0)

---SignalA Response Header----
Server: Microsoft-IIS/7.5

---SignalR Android Response Header----
Server: Microsoft-IIS/8.0

Below is the sequence of request, and it remains trying to reconnect infinitely :
/Authenticate 85 private application/json; charset=utf-8
/signalr/negotiate?clientProtocol=1.3&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 358 no-cache; Expires: -1 application/json; charset=UTF-8
/signalr/connect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 223 no-cache; Expires: -1 text/event-stream
/signalr/send?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 19 no-cache; Expires: -1 application/json; charset=UTF-8
/signalr/reconnect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 30 no-cache; Expires: -1 text/event-stream
/signalr/reconnect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&messageId=d-E71E368E-R%2C1%7CS%2C0%7CT%2C1%7CU%2C0&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 45 no-cache; Expires: -1 text/event-stream
/signalr/reconnect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&messageId=d-E71E368E-R%2C1%7CS%2C0%7CT%2C1%7CU%2C0&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 30 no-cache; Expires: -1 text/event-stream
/signalr/reconnect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&messageId=d-E71E368E-R%2C1%7CS%2C0%7CT%2C1%7CU%2C0&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 30 no-cache; Expires: -1 text/event-stream
/signalr/reconnect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&messageId=d-E71E368E-R%2C1%7CS%2C0%7CT%2C1%7CU%2C0&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 30 no-cache; Expires: -1 text/event-stream
/signalr/reconnect?transport=serverSentEvents&connectionToken=jgK8YIMWaPVJXwdclX2KGhDhJMWKQMwyZ%2FbsF51n84vZ9%2BKgP2Mnik%2B95yygLBOalLIv8FOsc1Hx7hREG7OsYv3BdMsuZC9mXocMBqF111Lalk%2BGS%2F2LS94pujwfuCCW&connectionId=db127c45-0d4b-4c7b-be5d-ffb62c1e9764&messageId=d-E71E368E-R%2C1%7CS%2C0%7CT%2C1%7CU%2C0&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D& 45 no-cache; Expires: -1 text/event-stream

FedAuth cookie from ADFS cannot be used as CookieCredential

The FedAuth cookie generated by ADFS contains semicolons and a mix of Base64 encoded text and non-Base64 encoded text. The ARRAffinity cookie generated by Azure also contains semicolons. Neither of these cookies appears to be able to be used with CookieCredential, since the "cookie" header value is delimited by semicolons. How can we use cookies containing semicolons and different encodings?

Example cookie values:

FedAuth=[Base64-encoded token]; expires=Sat, 07-Feb-2015 09:49:31 GMT; path=/; secure; HttpOnly
ARRAffinity=[long number];Path=/;Domain=site.azurewebsites.net

client-test-integration-android : InvalidHttpStatusCodeException

I am trying to run the signalR self-host example server (www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host) with the android test integration. I have tested that the self-host server is accessible by clients written in C# from another machine in the local network (I changed localhost to * on the server). However, I have not been successful yet. I get the following error:

Critical: AutomaticTransport - Error: microsoft.aspnet.signalr.client.http.InvalidHttpStatusCodeException: Invalid status code: 500

The full log can be seen here:

http://pastebin.com/fMPabbN1

Am I missing something? It does not look like a compilation or IP configuration error. If I don't run the server and run the tests, I get socketTimeOut, which is expected.

I ran the "Basic Connection Flow - Auto" test.

Thanks!

Imports not resolving

Hi,

I'm having trouble resolving the imports of the signalr-client-sdk package. I built the jar for signalr-client-sdk and placed all required jars in my android workspace libs folder. I've added the jars to the project build path. Please see the screenshots attached. As you can see the two imports are not resolving. I've cleaned the project and read a few forums but can't get passed this basic step.I hope I'm making a simple mistake. Any advice would be appreciated. Thanks.

signalr_java_class_resolve_error

signalr_java_build_path

Not able to run tests properly

HI,

I tried to run Android JUnit Test but console shows as following,

[2014-11-05 10:55:10 - signalr-client-test-integration-android] Performing android.test.InstrumentationTestRunner JUnit launch
[2014-11-05 10:55:10 - signalr-client-test-integration-android] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-11-05 10:55:56 - signalr-client-test-integration-android] Uploading signalr-client-test-integration-android.apk onto device 'c160725e7185a8f'
[2014-11-05 10:55:56 - signalr-client-test-integration-android] Installing signalr-client-test-integration-android.apk...
[2014-11-05 10:56:01 - signalr-client-test-integration-android] Success!
[2014-11-05 10:56:01 - signalr-client-test-integration-android] Launching instrumentation android.test.InstrumentationTestRunner on c160725e7185a8f
[2014-11-05 10:56:01 - signalr-client-test-integration-android] Failed to launch test

How can i able to run all these signaR Tests via JUnit. And If i starts installed application manually and try to run checked tests, those are failing... with bellow log

11-05 11:01:00.415: D/SIGNALR-TEST-INTEGRATION(14919): TEST COMPLETED - Basic connection flow - ServerSentEvents - Failed - Ex: ExecutionException: java.net.SocketTimeoutException: failed to connect to /10.0.0.1 (port 10001) after 15000ms // >SocketTimeoutException: failed to connect to /10.0.0.1 (port 10001) after 15000ms //

Add support for SignalR 1.2.x protocol

Hello guys, thanks for your work!

How can I use the official Java (Android) SDK to communicate with the back-end via SignalR 1.2.x protocol? As far as I can see by SignalR SDK code there is just a hard coded verification for 1.3 version at Connection.verifyProtocolVersion:

private static boolean verifyProtocolVersion(String versionString) {

Will it work for SignalR 1.2.x protocol if I will modify the verification to accept 1.2 also?

Thanks

Does not Disconnect Instantly as connection in SignalR

SignalR Get Connect in an instant. But does not disconnect when the data Connection get closed automatically on the other hand if the Client is a browser Client gets disconnect in an instant if client is closed. Hence Creating Problem, How to disconnect in instant when Client loses Connectivity with Server

ArrayIndexOutOfBoundsException causes disconnect

The following exception occurs at random. I can see in the trace that this has something to do with data which is coming in from the server, but got corrupt during the transfer. When this happens, the connection gets closed immediately.

The environment is an Android phone (Nexus 5) with Lollipop 5.0.1 and the latest version of the SignalR java-client.

I got the following exception from the error callback event:

01-15 14:29:54.111   9835-11514/com.mycompany.app E/wsp-signalr﹕ java.lang.ArrayIndexOutOfBoundsException
            at com.android.okio.Util.checkOffsetAndCount(Util.java:29)
            at com.android.okio.OkBuffer.skip(OkBuffer.java:391)
            at com.android.okio.OkBuffer.readUtf8Line(OkBuffer.java:331)
            at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:96)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.readChunkSize(HttpConnection.java:510)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.read(HttpConnection.java:491)
            at com.android.okio.RealBufferedSource$1.read(RealBufferedSource.java:168)
            at java.io.InputStreamReader.read(InputStreamReader.java:231)
            at java.io.BufferedReader.fillBuf(BufferedReader.java:145)
            at java.io.BufferedReader.readLine(BufferedReader.java:397)
            at microsoft.aspnet.signalr.client.http.StreamResponse.readToEnd(StreamResponse.java:72)
            at microsoft.aspnet.signalr.client.transport.LongPollingTransport$1.onResponse(LongPollingTransport.java:107)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:82)
            at java.lang.Thread.run(Thread.java:818)
01-15 14:29:54.187   9835-11517/com.mycompany.app E/wsp-signalr﹕ java.lang.Exception: Connection closed
            at microsoft.aspnet.signalr.client.hubs.HubProxy$2.run(HubProxy.java:229)
            at microsoft.aspnet.signalr.client.hubs.HubProxy$2.run(HubProxy.java:219)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.clearInvocationCallbacks(HubConnection.java:175)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.onClosed(HubConnection.java:163)
            at microsoft.aspnet.signalr.client.Connection.disconnect(Connection.java:550)
            at microsoft.aspnet.signalr.client.Connection$7.run(Connection.java:496)
            at microsoft.aspnet.signalr.client.Connection$7.run(Connection.java:490)
            at microsoft.aspnet.signalr.client.SignalRFuture.setResult(SignalRFuture.java:73)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:83)
            at java.lang.Thread.run(Thread.java:818)
01-15 14:29:54.187   9835-11517/com.mycompany.app E/wsp-signalr﹕ java.lang.Exception: Connection closed
            at microsoft.aspnet.signalr.client.hubs.HubProxy$2.run(HubProxy.java:229)
            at microsoft.aspnet.signalr.client.hubs.HubProxy$2.run(HubProxy.java:219)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.clearInvocationCallbacks(HubConnection.java:175)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.onClosed(HubConnection.java:163)
            at microsoft.aspnet.signalr.client.Connection.disconnect(Connection.java:550)
            at microsoft.aspnet.signalr.client.Connection$7.run(Connection.java:496)
            at microsoft.aspnet.signalr.client.Connection$7.run(Connection.java:490)
            at microsoft.aspnet.signalr.client.SignalRFuture.setResult(SignalRFuture.java:73)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:83)
            at java.lang.Thread.run(Thread.java:818)
01-15 14:29:54.188   9835-11517/com.mycompany.app E/wsp-signalr﹕ java.lang.Exception: Connection closed
            at microsoft.aspnet.signalr.client.hubs.HubProxy$2.run(HubProxy.java:229)
            at microsoft.aspnet.signalr.client.hubs.HubProxy$2.run(HubProxy.java:219)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.clearInvocationCallbacks(HubConnection.java:175)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.onClosed(HubConnection.java:163)
            at microsoft.aspnet.signalr.client.Connection.disconnect(Connection.java:550)
            at microsoft.aspnet.signalr.client.Connection$7.run(Connection.java:496)
            at microsoft.aspnet.signalr.client.Connection$7.run(Connection.java:490)
            at microsoft.aspnet.signalr.client.SignalRFuture.setResult(SignalRFuture.java:73)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:83)
            at java.lang.Thread.run(Thread.java:818)

How to Get a Value by public <E> SignalRFuture<E> invoke(final Class<E> resultClass, final String method, Object... args)

i try the way 1 (by handler),i can recieve the result, code as below:

hub.on("receiveHelloWorldReturn",
new SubscriptionHandler1() {
@OverRide
public void run(String msg) {

                            Log.i("0.03", "結果" + msg);
                            Toast.makeText(MainActivity.this, msg,
                                    Toast.LENGTH_LONG).show();
                        }
                    }, String.class);
            hub.invoke("HelloWorldReturn");

But i try the way 2 ( direct ), i can't receieve the result,

Class resultClass = null;
SignalRFuture str = hub.invoke(resultClass,
"HelloWorld2", "123");
str.done(new Action() {
@OverRide
public void run(String arg0) throws Exception {
Log.i("0.03", "arg0=" + arg0);
}
}).onError(new ErrorCallback() {
@OverRide
public void onError(Throwable error) {
Log.i("0.03", "error=" + error.toString());
}
});


Could Anyone help me, please...

Hangs on Sprint Network

In testing the java-client on several Sprint Android devices (US provider), I've had issues using the Sprint data network where it will hang/wait-for-timeout on the SignalRFuture get() line "mResultSemaphore.tryAcquire(timeout, unit)".

Works fine on AT&T and Verizon data networks and when the Sprint device is on WiFi.

I made a small change locally to SignalRFuture.java in microsoft.aspnet.signalr.client that appears to be working on all networks. I simply updated this:

private Semaphore mResultSemaphore = new Semaphore(0);

to this:

private Semaphore mResultSemaphore = new Semaphore(1);

Just wanted to pass this on.

Calling hub.Invoke() To many times causes an Exception

Hey,
I have been calling the invoke method of the HubProxy class, many times around 40 times each session and after 3 or 4 consecutive sessions the Application would crash with all kind of reasons like

Caused by: android.os.TransactionTooLargeException
android.view.Surface$OutOfResourcesException: eglMakeCurrent failed EGL_BAD_ALLOC
java.lang.RuntimeException: Could not read input channel file descriptors from parcel.

After some investigating i realized that the error is from the invoke method and probably because it's creating to many InputStreamReader or something of that kind.

Hope to get your input about this soon

Thanks
Shimi

NullPointerExcepetion --> SignalR Android Service

I´m running signalR as a Service (Android) and the error below occur very often:

java.lang.NullPointerException
at microsoft.aspnet.signalr.client.Connection.reconnect(Connection.java:795)
at microsoft.aspnet.signalr.client.Connection.onError(Connection.java:765)
at microsoft.aspnet.signalr.client.Connection$2.onError(Connection.java:325)
at microsoft.aspnet.signalr.client.SignalRFuture.triggerError(SignalRFuture.java:185)
at microsoft.aspnet.signalr.client.transport.AutomaticTransport$2.onError(AutomaticTransport.java:107)
at microsoft.aspnet.signalr.client.SignalRFuture.triggerError(SignalRFuture.java:185)
at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:92)
at java.lang.Thread.run(Thread.java:841)

Could you help me, please?

Thank you!

SignalR keep reconnect by itself after connected immediately and use 120s for reconnect

LOG CAT

01-22 15:37:50.102 7939-8795/com.example.SignalRRR I/System.out﹕ stateChanged From [Connected] To [Reconnecting]
01-22 15:39:32.932 7939-8905/com.example.SignalRRR I/System.out﹕ stateChanged From [Reconnecting] To [Connected]
01-22 15:39:35.162 7939-8952/com.example.SignalRRR I/System.out﹕ stateChanged From [Connected] To [Reconnecting]
01-22 15:41:23.122 7939-9052/com.example.SignalRRR I/System.out﹕ stateChanged From [Reconnecting] To [Connected]
01-22 15:41:25.352 7939-9359/com.example.SignalRRR I/System.out﹕ stateChanged From [Connected] To [Reconnecting]
01-22 15:43:13.642 7939-9478/com.example.SignalRRR I/System.out﹕ stateChanged From [Reconnecting] To [Connected]
01-22 15:43:15.872 7939-9481/com.example.SignalRRR I/System.out﹕ stateChanged From [Connected] To [Reconnecting]
01-22 15:45:13.652 7939-9501/com.example.SignalRRR I/System.out﹕ stateChanged From [Reconnecting] To [Connected]
01-22 15:45:15.892 7939-9505/com.example.SignalRRR I/System.out﹕ stateChanged From [Connected] To [Reconnecting]

code snippet for establish connection

   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        System.setProperty("http.keepAlive", "true");

        final HubConnection connection = createHubConnection();
        final ClientTransport transport = createTransport(TransportType.LongPolling);
        final HubProxy proxy = connection.createHubProxy("MyHub");

        try {
            connection.start(transport).get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }

Signal Host C#

using System;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Owin;
using Microsoft.Owin.Cors;
using System.Collections.Generic;


namespace SignalRHost
{
    class Program
    {
        static void Main(string[] args)
        {
            // This will *ONLY* bind to localhost, if you want to bind to all addresses
            // use http://*:8080 to bind to all addresses. 
            // See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx 
            // for more information.
            string url = "http://*:8080";
            using (WebApp.Start(url))
            {
                Console.WriteLine("Server running on {0}", url);
                Console.ReadLine();
            }
        }
    }
    class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);
            app.MapSignalR();
        }
    }
    public class MyHub : Hub
    {

        public void Send(string name, string message)
        {
            Clients.All.addMessage(name, message);
        }
    }
}

The type SubscriptionHandler is not generic; it cannot be parameterized with arguments <String>

i can send message from android client to server use signalR client.
but i want to define methods on the client that the server can call as follow:

public void UpdateStatus( String status )
{
final String fStatus = status;
handler.post(new Runnable(){
@OverRide
public void run() {
statusField.setText( fStatus );
}});
}
but i got a problem when i wrote hub.on()
hub.on( "UpdateStatus",
new SubscriptionHandler() {
@OverRide
public void run( String status ) {
// Since we are updating the UI,
// we need to use a handler of the UI thread.
final String fStatus = status;
handler.post( new Runnable() {
@OverRide
public void run() {
statusField.setText( fStatus );
}
} );
}
}
, String.class );
the new SubscriptionHandler throws an exception:
The type SubscriptionHandler is not generic; it cannot be parameterized with arguments

Fail parse DateTime without DateTimeOffset

The orig data is "2015-02-06T19:58:00.277"

com.google.gson.JsonParseException: java.text.ParseException: Unparseable date: "2015-02-06T19:58:00000000.77" (at offset 28)
at microsoft.aspnet.signalr.client.DateSerializer.deserialize(DateSerializer.java:41)
at microsoft.aspnet.signalr.client.DateSerializer.deserialize(DateSerializer.java:27)
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.Gson.fromJson(Gson.java:810)
at com.google.gson.Gson.fromJson(Gson.java:875)
at com.google.gson.Gson.fromJson(Gson.java:848)
at microsoft.aspnet.signalr.client.hubs.HubProxy$1.run(HubProxy.java:155)
at microsoft.aspnet.signalr.client.hubs.HubProxy$1.run(HubProxy.java:141)
at microsoft.aspnet.signalr.client.hubs.Subscription.onReceived(Subscription.java:31)
at microsoft.aspnet.signalr.client.hubs.HubProxy.invokeEvent(HubProxy.java:413)
at microsoft.aspnet.signalr.client.hubs.HubConnection.onReceived(HubConnection.java:118)
at microsoft.aspnet.signalr.client.transport.TransportHelper.processReceivedData(TransportHelper.java:96)
at microsoft.aspnet.signalr.client.Connection.processReceivedData(Connection.java:739)
at microsoft.aspnet.signalr.client.Connection.access$000(Connection.java:30)
at microsoft.aspnet.signalr.client.Connection$10.onData(Connection.java:677)
at microsoft.aspnet.signalr.client.transport.LongPollingTransport$1.onResponse(LongPollingTransport.java:113)
at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:82)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.text.ParseException: Unparseable date: "2015-02-06T19:58:00000000.77" (at offset 28)
at java.text.DateFormat.parse(DateFormat.java:555)
at microsoft.aspnet.signalr.client.DateSerializer.deserialize(DateSerializer.java:104)
at microsoft.aspnet.signalr.client.DateSerializer.deserialize(DateSerializer.java:39)
            at microsoft.aspnet.signalr.client.DateSerializer.deserialize(DateSerializer.java:27)
            at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
            at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
            at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
            at com.google.gson.Gson.fromJson(Gson.java:810)
            at com.google.gson.Gson.fromJson(Gson.java:875)
            at com.google.gson.Gson.fromJson(Gson.java:848)
            at microsoft.aspnet.signalr.client.hubs.HubProxy$1.run(HubProxy.java:155)
            at microsoft.aspnet.signalr.client.hubs.HubProxy$1.run(HubProxy.java:141)
            at microsoft.aspnet.signalr.client.hubs.Subscription.onReceived(Subscription.java:31)
            at microsoft.aspnet.signalr.client.hubs.HubProxy.invokeEvent(HubProxy.java:413)
            at microsoft.aspnet.signalr.client.hubs.HubConnection.onReceived(HubConnection.java:118)
            at microsoft.aspnet.signalr.client.transport.TransportHelper.processReceivedData(TransportHelper.java:96)
            at microsoft.aspnet.signalr.client.Connection.processReceivedData(Connection.java:739)
            at microsoft.aspnet.signalr.client.Connection.access$000(Connection.java:30)
            at microsoft.aspnet.signalr.client.Connection$10.onData(Connection.java:677)
            at microsoft.aspnet.signalr.client.transport.LongPollingTransport$1.onResponse(LongPollingTransport.java:113)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:82)
            at java.lang.Thread.run(Thread.java:841)

Failed to build application

once i added jar files and start build my app
Error:Execution failed for task ':app:preDexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\AA\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --output C:\Users\AA\AndroidStudioProjects\TheMahen\app\build\intermediates\pre-dexed\debug\signalr-client-sdk-c4e83deedf5e75d371f36ddf7d9d040bf8a3121a.jar C:\Users\AA\AndroidStudioProjects\TheMahen\app\libs\signalr-client-sdk.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing microsoft/aspnet/signalr/client/Action.class
1 error; aborting

build.gradle
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.puretecheg.myapplication"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/signalr-client-sdk-android.jar')
compile files('libs/signalr-client-sdk.jar')
compile files('libs/gson-2.2.2.jar')
}

How can i Set Timeout for SignalR Technology Fallback in SignalR/Client Java

I know if a connection is not made SignalR will fallback from Websocket to SSE to ... to long pooling. I wanna know how can i set Timeout period for each technology to switch for example let us say if a connection is not made in 2 Sec then fallback to another technology. I wanna set those 2 Sec.

How can i create this code in Android.

Verify valid protocol version?

I have asked a question on StackOverflow, but I figuired I would post it here also.

http://stackoverflow.com/questions/22997568/signalr-java-client-only-supports-exactly-1-3

Is there a reason why the Java client for SignalR only supports exactly version 1.3?

private static boolean verifyProtocolVersion(String versionString) {

Shouldn't all clients be backwards compatible? Is there any harm done and changing the verifyProtocolVersion method to verify that the protocol is less than or equal to 1.3?

For testing purposes, I simply returned true, skipping the entire method body, to see if it worked with my 1.2.1 server, and it did.

Maybe this should be considered a bug?

AndroidTestPlatformContext class in Android TestProject

Hi, I am unable to run the provided TestProject. Because i am getting the following error.
Could you please help me on this? AndroidTestPlatformContext class is created by you and its not related with android(not extending any android's built in class) then why i am getting the following Exception. See the log...

11-04 18:24:16.054: E/AndroidRuntime(6737): FATAL EXCEPTION: main
11-04 18:24:16.054: E/AndroidRuntime(6737): java.lang.NoClassDefFoundError: microsoft.aspnet.signalr.client.test.integration.android.AndroidTestPlatformContext
11-04 18:24:16.054: E/AndroidRuntime(6737): at microsoft.aspnet.signalr.client.test.integration.android.MainActivity.onCreate(MainActivity.java:65)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.Activity.performCreate(Activity.java:5163)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.os.Looper.loop(Looper.java:137)
11-04 18:24:16.054: E/AndroidRuntime(6737): at android.app.ActivityThread.main(ActivityThread.java:4895)
11-04 18:24:16.054: E/AndroidRuntime(6737): at java.lang.reflect.Method.invokeNative(Native Method)
11-04 18:24:16.054: E/AndroidRuntime(6737): at java.lang.reflect.Method.invoke(Method.java:511)
11-04 18:24:16.054: E/AndroidRuntime(6737): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
11-04 18:24:16.054: E/AndroidRuntime(6737): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
11-04 18:24:16.054: E/AndroidRuntime(6737): at dalvik.system.NativeStart.main(Native Method)

Any help will be appreciated.

removeSubscription

HubProxy.removeSubscription doesn't seem to be removing client event subscription. Tried unsubscribing from events instantiated with both - HubProxy.subscribe(event) and HubProxy.on(event, handler). When calling removeSubscription, debugger still shows there's a subscription, and on subsequent calls to subscribe again, fires events twice.

Could not find class 'microsoft.aspnet.signalr.client.transport.WebsocketTransport$1', referenced from method microsoft.aspnet.signalr.client.transport.WebsocketTransport.start

Hello,

I cloned the project and built it as it is told in the 'readme' file. On Android client, when I tried to connect my hub. I get this error : Could not find class 'microsoft.aspnet.signalr.client.transport.WebsocketTransport$1', referenced from method microsoft.aspnet.signalr.client.transport.WebsocketTransport.start

any idea?

thanks

Nested json object does not parse correctly.

We are sending(from .net server) an object that looks like this:

{
"created": "2014-09-24T22:29:55.9433573+00:00",
"payload": {
"locationId": "sadfasdfasdf",
"sdid": "adsfasdf",
"timestamp": "2014-09-24T22:29:55.9433573+00:00",
"x": 3.35827106766322,
"y": 28.6876492754964,
"confidenceFactor": 100
},
"subscriptionType": "Update"
}

Ends up receiving (java hub client) parsed into an object that looks like this (the quotes on the payload nested object are missing making it hard to parse the nested object):

{
"created": "2014-09-24T22:29:55.9433573+00:00",
"payload": {locationId:sadfasdfasdf,sdid:adsfasdf,timestamp:2014-09-24T22:29:55.9433573+00:00,x:3.35827106766322,y:28.6876492754964,confidenceFactor:100},
"subscriptionType": "Update"
}

Need to update repository

http://maven.eclipse.org/ does not appear to exist any longer, so mvn package fails with the following error:

[ERROR] Failed to execute goal on project signalr-client-sdk: Could not resolve dependencies for project micros
oft.aspnet.signalr:signalr-client-sdk:jar:1.0: Failed to collect dependencies at com.google.code.gson:gson:jar:
2.2.2: Failed to read artifact descriptor for com.google.code.gson:gson:jar:2.2.2: Could not transfer artifact
com.google.code.gson:gson:pom:2.2.2 from/to central (http://maven.eclipse.org/build): Connect to maven.eclipse.
org:80 [maven.eclipse.org/198.41.30.249] failed: Connection timed out: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Simply removing the repositories section from the pom, or changing the URL to http://repo.maven.apache.org/maven2 resolves this error.

To reproduce this behavior, clone the repository and run the following from the signalr-client-sdk folder:
mvn package

NOTE: if you have previously cached the Gson package on the build machine, you must first remove the cached bits by doing something like rm -r -f \users\username.m2\repository\com\google\code\gson. Otherwise, it will appear to work fine since it finds the bits locally.

3G Connection

I need to do something special for work with a 3G connection?

My app works fine with Wifi, but doesn't work with a 3G connection.

Hang after calling 'connection.start().get()' on Android.

I'm attempting to run the following code on an Android client using the head revision of the repo:

...
// Change to the IP address and matching port of your SignalR server.
connection = new HubConnection("http://fa-signalr-demo.azurewebsites.net/", "", true, logger);
hub = connection.createHubProxy("chatHub");
...

// This code is an async task so that it wouldn't hang the main thread when debugging.
SignalRFuture<Void> awaitConnection = connection.start();
try {
    awaitConnection.get();
}
catch (InterruptedException e) {
    e.printStackTrace();
} catch (ExecutionException e) {
    e.printStackTrace();
}
...

However the get() function never returns and no connection seems to get established. If I attempt to do anything with the connection object after this point, an exception is thrown as it is in a 'Connecting' state but it never moves from this state.

Befire hanging the last log ouput is:

01-27 21:03:22.512: I/SignalR(13738): HubConnection - Getting connection data: [{"name":"chathub"}]

This is occuring on multiple devices: a Samsung Galaxy S4 with Android 4.4.2 and a Motorola X wtih Android 4.4.4, are the devices I'm using most often.

Has anyone run in a similar problem or can offer any advice?

Thanks

Full Log:

01-27 21:03:19.039: W/ActivityThread(13738): Application com.example.signalrchat is waiting for the debugger on port 8100...
01-27 21:03:19.049: I/System.out(13738): Sending WAIT chunk
01-27 21:03:19.049: I/dalvikvm(13738): Debugger is active
01-27 21:03:19.249: I/System.out(13738): Debugger has connected
01-27 21:03:19.249: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:19.449: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:19.649: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:19.850: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:20.050: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:20.250: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:20.450: I/System.out(13738): waiting for debugger to settle...
01-27 21:03:20.660: I/System.out(13738): debugger has settled (1449)
01-27 21:03:20.690: W/ApplicationPackageManager(13738): getCSCPackageItemText()
01-27 21:03:20.690: I/PersonaManager(13738): getPersonaService() name persona_policy
01-27 21:03:20.861: I/SignalR(13738): HubConnection - Creating hub proxy: chathub
01-27 21:03:20.881: I/SignalR(13738): HubProxy chatHub - Subscribe to event broadcastMessage
01-27 21:03:20.881: I/SignalR(13738): HubProxy chatHub - Creating new subscription for: broadcastmessage
01-27 21:03:20.941: I/SignalR(13738): HubConnection - Entered startLock in start
01-27 21:03:20.941: I/SignalR(13738): State Changed- Connecting
01-27 21:03:20.951: I/SignalR(13738): HubConnection - Start the connection, using AutomaticTransport transport
01-27 21:03:20.951: I/SignalR(13738): HubConnection - Start negotiation
01-27 21:03:20.951: I/SignalR(13738): AutomaticTransport - Start the negotiation with the server
01-27 21:03:21.061: I/Adreno-EGL(13738): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:  (CL3869936)
01-27 21:03:21.061: I/Adreno-EGL(13738): OpenGL ES Shader Compiler Version: 17.01.11.SPL
01-27 21:03:21.061: I/Adreno-EGL(13738): Build Date: 01/17/14 Fri
01-27 21:03:21.061: I/Adreno-EGL(13738): Local Branch: 
01-27 21:03:21.061: I/Adreno-EGL(13738): Remote Branch: 
01-27 21:03:21.061: I/Adreno-EGL(13738): Local Patches: 
01-27 21:03:21.061: I/Adreno-EGL(13738): Reconstruct Branch: 
01-27 21:03:21.071: I/SignalR(13738): HubConnection - Getting connection data: [{"name":"chathub"}]
01-27 21:03:21.081: I/SignalR(13738): HubConnection - Getting connection data: [{"name":"chathub"}]
01-27 21:03:21.081: I/SignalR(13738): AutomaticTransport - Execute the request
01-27 21:03:21.081: I/SignalR(13738): Create new thread for HTTP Connection
01-27 21:03:21.091: I/SignalR(13738): Execute the HTTP Request
01-27 21:03:21.091: I/SignalR(13738): URL: http://fa-signalr-demo.azurewebsites.net/signalr/negotiate?clientProtocol=1.3&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&
01-27 21:03:21.091: I/SignalR(13738): VERB: GET
01-27 21:03:21.091: I/SignalR(13738): Header User-Agent: SignalR (lang=Java; os=android; version=2.0)
01-27 21:03:21.091: I/SignalR(13738): CONTENT: null
01-27 21:03:21.101: D/OpenGLRenderer(13738): Enabling debug mode 0
01-27 21:03:21.281: V/RenderScript(13738): 0x7949c7b0 Launching thread(s), CPUs 4
01-27 21:03:22.232: I/SignalR(13738): Request executed
01-27 21:03:22.492: I/SignalR(13738): AutomaticTransport - Response received
01-27 21:03:22.492: I/SignalR(13738): AutomaticTransport - Read response data to the end
01-27 21:03:22.492: I/SignalR(13738): AutomaticTransport - Trigger onSuccess with negotiation data: {"Url":"/signalr","ConnectionToken":"9GTf9SuWo5p3VFOU2Rb1ohoVEclbIlQtsFj/mgCzmd2Dr1Zx7GVUi+TSRodi83lsEt9HUe9d2rz9oLPNXT7IKKd7valdgmXY0AoPifyalxcErRCTJtYOyxi/3mgM5IqO","ConnectionId":"25d6320a-5db4-4148-8ac6-a421c5d8ae4f","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true,"ProtocolVersion":"1.3","TransportConnectTimeout":5.0,"LongPollDelay":0.0}
01-27 21:03:22.502: I/SignalR(13738): HubConnection - Negotiation completed
01-27 21:03:22.502: I/SignalR(13738): HubConnection - ConnectionId: 25d6320a-5db4-4148-8ac6-a421c5d8ae4f
01-27 21:03:22.502: I/SignalR(13738): HubConnection - ConnectionToken: 9GTf9SuWo5p3VFOU2Rb1ohoVEclbIlQtsFj/mgCzmd2Dr1Zx7GVUi+TSRodi83lsEt9HUe9d2rz9oLPNXT7IKKd7valdgmXY0AoPifyalxcErRCTJtYOyxi/3mgM5IqO
01-27 21:03:22.512: I/SignalR(13738): HubConnection - Keep alive timeout: 20.0
01-27 21:03:22.512: I/SignalR(13738): HubConnection - Entered startLock in startTransport
01-27 21:03:22.512: I/SignalR(13738): HubConnection - Starting the transport
01-27 21:03:22.512: I/SignalR(13738): HubConnection - Starting transport for InitialConnection
01-27 21:03:22.512: I/SignalR(13738): HubConnection - Getting connection data: [{"name":"chathub"}]
01-27 21:03:22.512: I/SignalR(13738): HubConnection - Getting connection data: [{"name":"chathub"}]

HubProxy.invoke Callbacks are useless.

Please, add callbacks like OnInvokeListener interface. It may invoke OnSuccess(parameters) or OnFail(parameters).

getResult() is useless method for Android UI processing.

For now, i added my OnInvokeListener.

I use it like:
mHubProxy.invoke(methodName, new OnInvokeListener(){
@OverRide
public void OnInvokeDone() {
// TODO: DONE
}
@OverRide
public void OnInvokeError() {
// TODO: ERROR
}
}, arguments);

Modified HubProxy.invoke method:

/**
 * Invokes a hub method that returns a value
 * 
 * @param method
 *            Method name
 * @param mOnInvokeListener
 *            Method callback
 * @param args
 *            Method arguments
 * @return A Future for the operation, that will return the method result
 */
public <E> SignalRFuture<E> invoke(final Class<E> resultClass, final String method, final OnInvokeListener mOnInvokeListener, Object... args) {
    if (method == null) {
        throw new IllegalArgumentException("method cannot be null");
    }
    if (args == null) {
        throw new IllegalArgumentException("args cannot be null");
    }
    log("Invoking method on hub: " + method, LogLevel.Information);
    JsonElement[] jsonArguments = new JsonElement[args.length];

    for (int i = 0; i < args.length; i++) {
        jsonArguments[i] = mConnection.getGson().toJsonTree(args[i]);
    }
    final SignalRFuture<E> resultFuture = new SignalRFuture<E>();
    final String callbackId = mConnection.registerCallback(new Action<HubResult>() {
        @Override
        public void run(HubResult result) {
            log("Executing invocation callback for: " + method, LogLevel.Information);
            if (result != null) {
                if (result.getError() != null) {
                    if (result.isHubException()) {
                        resultFuture.triggerError(new HubException(result.getError(), result.getErrorData()));
                    } else {
                        resultFuture.triggerError(new Exception(result.getError()));
                    }
                    try {
                        if(mOnInvokeListener!=null)
                            mOnInvokeListener.OnInvokeError();
                    }
                    catch (Exception e) {
                    }
                } else {
                    boolean errorHappened = false;
                    E resultObject = null;
                    try {
                        if (result.getState() != null) {
                            for (String key : result.getState().keySet()) {
                                setState(key, result.getState().get(key));
                            }
                        }
                        if (result.getResult() != null && resultClass != null) {
                            log("Found result invoking method on hub: " + result.getResult(), LogLevel.Information);
                            resultObject = mConnection.getGson().fromJson(result.getResult(), resultClass);
                        }
                    } catch (Exception e) {
                        errorHappened = true;
                        resultFuture.triggerError(e);
                        try {
                            if(mOnInvokeListener!=null)
                                mOnInvokeListener.OnInvokeError();
                        }
                        catch (Exception ex) {
                        }
                    }
                    if (!errorHappened) {
                        try {
                            resultFuture.setResult(resultObject);
                            try {
                                if(mOnInvokeListener!=null)
                                    mOnInvokeListener.OnInvokeDone();
                            }
                            catch (Exception e) {
                            }
                        } catch (Exception e) {
                            resultFuture.triggerError(e);
                            try {
                                if(mOnInvokeListener!=null)
                                    mOnInvokeListener.OnInvokeError();
                            }
                            catch (Exception ex) {
                            }
                        }
                    }
                }
            }
            else{
                try {
                    if(mOnInvokeListener!=null)
                        mOnInvokeListener.OnInvokeError();
                }
                catch (Exception e) {
                }
            }
        }
    });
    HubInvocation hubData = new HubInvocation();
    hubData.setHub(mHubName);
    hubData.setMethod(method);
    hubData.setArgs(jsonArguments);
    hubData.setCallbackId(callbackId);
    if (mState.size() != 0) {
        hubData.setState(mState);
    }
    final SignalRFuture<Void> sendFuture = mConnection.send(hubData);
    resultFuture.onCancelled(new Runnable() {
        @Override
        public void run() {
            mConnection.removeCallback(callbackId);
        }
    });
    resultFuture.onError(new ErrorCallback() {

        @Override
        public void onError(Throwable error) {
            sendFuture.triggerError(error);
        }
    });
    return resultFuture;
}

SignalR throws Exceptions in its own threads which aren't handled

Hi,

It appears that the SignalR connection throws unhandled exceptions inside its thread. There is no way to handle them in my application except for defining a global Thread.UncaughtExceptionHandler. This also affects my own threads, so this is not really the greatest solution. The exceptions occur mostly when I call the hubConnection.stop() method. Below I have included an example of Exceptions thrown by the connection Thread (an IndexOutOfBoundsException is also thrown sometimes, I will add the stacktrace when it occurs again):

11-18 11:06:07.998  24889-26148/com.mypackage E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-5420
    Process: com.mypackage, PID: 24889
    java.lang.NullPointerException: Attempt to read from field 'int com.android.okio.Segment.limit' on a null object reference
            at com.android.okio.OkBuffer.write(OkBuffer.java:574)
            at com.android.okio.OkBuffer.read(OkBuffer.java:610)
            at com.android.okio.RealBufferedSource.read(RealBufferedSource.java:53)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.read(HttpConnection.java:495)
            at com.android.okhttp.internal.Util.skipAll(Util.java:227)
            at com.android.okhttp.internal.http.HttpConnection.discard(HttpConnection.java:212)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.close(HttpConnection.java:536)
            at com.android.okhttp.internal.Util.closeQuietly(Util.java:97)
            at com.android.okhttp.internal.http.HttpEngine.close(HttpEngine.java:433)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.disconnect(HttpURLConnectionImpl.java:113)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.closeStreamAndConnection(NetworkRunnable.java:106)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:95)
            at java.lang.Thread.run(Thread.java:818)

It would be nice if the exceptions inside threads are handled.

Thanks :)

Edit (added IndexOutOfBoundsException):

11-18 11:29:58.996  30513-31434/com.mypackage E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-5682
    Process: com.mypackage, PID: 30513
    java.lang.ArrayIndexOutOfBoundsException
            at com.android.okio.Util.checkOffsetAndCount(Util.java:29)
            at com.android.okio.OkBuffer.skip(OkBuffer.java:391)
            at com.android.okio.OkBuffer.readUtf8Line(OkBuffer.java:331)
            at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:96)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.readChunkSize(HttpConnection.java:508)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.read(HttpConnection.java:491)
            at com.android.okhttp.internal.Util.skipAll(Util.java:227)
            at com.android.okhttp.internal.http.HttpConnection.discard(HttpConnection.java:212)
            at com.android.okhttp.internal.http.HttpConnection$ChunkedSource.close(HttpConnection.java:536)
            at com.android.okhttp.internal.Util.closeQuietly(Util.java:97)
            at com.android.okhttp.internal.http.HttpEngine.close(HttpEngine.java:433)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.disconnect(HttpURLConnectionImpl.java:113)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.closeStreamAndConnection(NetworkRunnable.java:106)
            at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:95)
            at java.lang.Thread.run(Thread.java:818)

Signalr Java client disconnected instead of reconnect

Hi
we are using SignalR java client for android app to receive signalr notifications.
We have noticed that when user off the wi-fi,it immediately disconnected from the server instead of calling onreconnect event.It should call to reconnect event and if internet not available with in 30 seconds then it should call to disconnect event.

Depending on Wifi or 3G connection, start method needs LongPollingTransport instance

Hello,

I have an issue with SignalR java-client. it is simply, if my device has a WIFI connection I have to start connection with parameterless start method, otherwise I have to send a LongPollingTransport instance to start method. if I do not do this after a while SignalR disconnects thus it stops working properly.

In this case, I am making user to select what kind of connection his device has, but I really dont want my user to make this choice.

Could you please help me on this? thank you. I appreciate your help.

simply my code is

             lpt = new LongPollingTransport(new Logger() 
    {       
        @Override
        public void log(String message, LogLevel level) 
        {

        }
    });

    SignalRFuture<Void> awaitConnection = null;

    if(!wifi)
     awaitConnection = con.start(lpt);
    else
     awaitConnection = con.start();
    try
    {
        awaitConnection.get();
        connected=true;
        firstStart=false;
    } 
    catch (InterruptedException e)
    {
        ConnectExceptionRecieved();
    } 

ConcurrentModificationException

Dear Developers,

We have some problem in our android application, the app crash with the following stacktrace:

java.util.ConcurrentModificationException
       at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
       at microsoft.aspnet.signalr.client.SignalRFuture.cancel(SignalRFuture.java:52)
       at microsoft.aspnet.signalr.client.UpdateableCancellableFuture.cancel(UpdateableCancellableFuture.java:39)
       at microsoft.aspnet.signalr.client.Connection.disconnect(Connection.java:532)
       at microsoft.aspnet.signalr.client.Connection.onError(Connection.java:768)
       at microsoft.aspnet.signalr.client.Connection$2.onError(Connection.java:325)
       at microsoft.aspnet.signalr.client.SignalRFuture.triggerError(SignalRFuture.java:185)
       at microsoft.aspnet.signalr.client.transport.AutomaticTransport$2.onError(AutomaticTransport.java:116)
       at microsoft.aspnet.signalr.client.SignalRFuture.triggerError(SignalRFuture.java:185)
       at microsoft.aspnet.signalr.client.transport.LongPollingTransport$3.onError(LongPollingTransport.java:149)
       at microsoft.aspnet.signalr.client.SignalRFuture.triggerError(SignalRFuture.java:185)
       at microsoft.aspnet.signalr.client.http.java.NetworkRunnable.run(NetworkRunnable.java:92)
       at java.lang.Thread.run(Thread.java:841)

As you see, this issue is coming from the signalR library. Please let me know how can we avoid the problem, or if you can fix it, we would be happy.

Yours Sincerely,
Gergo

Date parsing failure when no milliseconds are in date string

Using the default serialization settings from SignalR 2.0.0, I get dates in the format 2014-03-29T00:00:00 or 2014-03-29T00:00:00Z. I would expect these dates to parse correctly, however I get the following exception:
java.text.ParseException: Unparseable date: "2014-03-29T000000000000:0000"

The only way I have discovered to get the Java client to parse the dates is to change my serialization settings in the SignalR server:

var serializerSettings = new JsonSerializerSettings();
serializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
serializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
serializerSettings.Converters.Add(new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd\\THH:mm:ss.fffK", DateTimeStyles = DateTimeStyles.AdjustToUniversal | DateTimeStyles.RoundtripKind});
var serializer = JsonSerializer.Create(serializerSettings);
// Register serializer in IOC

I don't particularly want to make this change, because this format is not desirable for our purposes.
Additionally, the Gson instance in the Java client cannot be overridden so I can't easily substitute my own Date parser.

Is there some obvious setting that I'm missing? I think the following formats should be parsed without error (right now they all throw a ParseException):

  • 2014-03-29T00:00:00 (assume UTC, or allow the behaviour to be configured)
  • 2014-03-29T00:00:00Z
  • 2014-03-29T00:00:00+00:00

I believe this is due to the fact that the DateSerializer implementation is inserting milliseconds, but not the milliseconds separator .. For this reason, 2014-03-29T00:00:00.Z (note the . before the Z) actually parses without error.

If this isn't possible, please allow the Gson instance to be overridden.

Incoming messages are sometimes delayed.

Server messages are sometimes delayed. I have an Android application with a contact list which updates the contact statuses (online/offline) realtime via SignalR. This is working fine, until after a random amount of time (sometimes ~10s, sometimes ~20s, sometimes even >60s). At this point statuses are no longer updated for a random amount of time. When the statuses start to update again, all the updates come through at once and normal behaviour is restored (until it stops and starts again).

This problem occurs on a Nexus 5 connected via Wifi and in an emulator on my desktop (connected via ethernet). The problems do not occur in the web version and the windows phone app, so I am pretty sure that the java-client is the cause of these problem.

I can imagine this issue is related to #54

Can not set Header for HubConnection

I want to add header to HubConnection for authentication but unable to do that!
I try to use this: conn.getHeaders().put(String, String), but it return null.

My app does not work in 3G connections

My app works well in WI-FI Connection. It works perfectly well in 2G as well but whenever i try to connect with 3G, it has issues and most of the time it don't make a connection sometime it makes connection after a long time (I am making a copy of Connection info in my database so i can check connection IDs from there), but rest of the part don't work.

Kindly suggest what kind of changes do i need to apply for 3G connection as i know speed is not the concern because its working in 2G.

LongPolling transport remains in reconnect state until server sends an event.

Hi,

I have an issue with the LongPolling transport. The problem is that when the server doesn't call any of the subscribed methods of the subscription object (provided through hubProxy.subscribe()), the signalr java client signals 'slow connection' and after a few seconds it will land in the reconnect state. When this happens, I am able to send data to the server using the hubProxy.invoke command while the client still stays in reconnect state. The data is handled as expected on the server. So no troubles here. But when I want to disconnect from the server, the connection remains open until the state has become 'reconnected'. The client will get only reconnected when the server invokes a subscription method on the client. So I am literally dependent of the server to call a method on my client side before I can close any connection.

Steps to reproduce:

  1. start a connection with longpolling transport
  2. create a hub proxy
  3. wait until the connection gets in reconnect mode
  4. perform some actions from the client to the server (which succeeds, while the connector says it isn't connected).
  5. close the connection from the client
  6. note that the connection doesn't disconnect
  7. try to invoke a client method from the server
  8. client gets reconnected and disconnected immediately.

Maven

It would be nice if the jars were published to maven. This would make it significantly easier to consume and get updates from this library.

Android SignalR java-client: Not receiving all the SignalR messages on the HubConnection

I've tried to receive the SignalR messages in several ways, but in any case I'm able to receive them always... I'm using the LongPollingTransport (maybe it is due to this), and I can see that the LongPolling log receives all the messages correctly but it only enters the handler method sometimes (in the others it seems to try to reconnect the server).

You can see more details on the StackOverflow question here: http://stackoverflow.com/questions/28587391/android-signalr-java-client-not-receiving-all-the-signalr-messages-on-the-hubco

I would really appreciate your help, because I'm are trying to move from SignalA (over a year without updates + some internal errors unhandled) to this library but at the moment I'm not able to receive all the messages, so I can't do it.

Many thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.