Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

how to create hubconnection with websocket for android client #64

Open
hirenpatel868 opened this issue Dec 27, 2018 · 21 comments
Open

how to create hubconnection with websocket for android client #64

hirenpatel868 opened this issue Dec 27, 2018 · 21 comments

Comments

@hirenpatel868
Copy link

No description provided.

@hirenpatel868 hirenpatel868 changed the title how to create hubconnection with websocket.. how to create hubconnection with websocket for android client Dec 27, 2018
@BrennanConroy
Copy link
Member

@hirenpatel868
Copy link
Author

Yes...but its asp.net core..my backend signalr is in asp.net....i used this asp.net core lib but failed to connect with signalr server

@BrennanConroy
Copy link
Member

Those are not compatible. You have to use either asp.net server with asp.net client, or asp.net core signalr with asp.net core client. You can't mix them.

@hirenpatel868
Copy link
Author

Do you any signarl java client which support websocket transport with asp.net signalr server .?

@BrennanConroy
Copy link
Member

There is https://github.com/SignalR/java-client however it is no longer maintained.

@hirenpatel868
Copy link
Author

hirenpatel868 commented Jan 3, 2019

Thnk you for you fast replay....i tried to generate jar files using this but i am not able to generate jar files..can you help me to build jar files using this java client..

@BrennanConroy
Copy link
Member

I've never used that client before so I have no idea how to use it sorry.

@mikaelm12
Copy link
Contributor

The client at https://github.com/SignalR/java-client has been deprecated. While SignalR on asp.net is still supported, just that specific client is no longer supported. 🙁

@gxh-apologize
Copy link

dear all
my backend signalr is in asp.net core 2.1 , but the java client is available in aps.net core 2.2 and later......
Who has a solution to tell me? thank u. My English is terrible. sorry.

@mikaelm12
Copy link
Contributor

Have you tried and run into issues using the SignalR Java client with your AspNetCore SignalR 2.1 app? It should work.

@hirenpatel868
Copy link
Author

@gxh-apologize i think so it should work..there is no version compatibility issue with .core signalr ....but if you have .net signalr as backend and you are using .net core signalr at front end then you faced version compatibility issues..

@gxh-apologize
Copy link

Have you tried and run into issues using the SignalR Java client with your AspNetCore SignalR 2.1 app? It should work.

04-18 14:09:14.827 3655-3724/cn.gxh.view E/OkHttpWebSocketWrapper: WebSocket closed from an error: Expected 'Connection' header value 'Upgrade' but was 'null'.
04-18 14:09:14.828 3655-3724/cn.gxh.view I/WebSocketTransport: WebSocket connection stopping with code null and reason 'Expected 'Connection' header value 'Upgrade' but was 'null''.
04-18 14:09:14.828 3655-3724/cn.gxh.view E/c*.m*.s*.HubConnection: HubConnection disconnected with an error Expected 'Connection' header value 'Upgrade' but was 'null'.

--------- beginning of crash

04-18 14:09:14.831 3655-3724/cn.gxh.view E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: cn.gxh.view, PID: 3655
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.microsoft.signalr.HubConnection$ConnectionState.cancelOutstandingInvocations(java.lang.Exception)' on a null object reference
at com.microsoft.signalr.HubConnection.stopConnection(HubConnection.java:431)
at com.microsoft.signalr.HubConnection.lambda$start$6$HubConnection(HubConnection.java:301)
at com.microsoft.signalr.HubConnection$$Lambda$19.invoke(Unknown Source)
at com.microsoft.signalr.WebSocketTransport.onClose(WebSocketTransport.java:93)
at com.microsoft.signalr.WebSocketTransport.lambda$start$1$WebSocketTransport(WebSocketTransport.java:56)
at com.microsoft.signalr.WebSocketTransport$$Lambda$1.invoke(Unknown Source)
at com.microsoft.signalr.OkHttpWebSocketWrapper$SignalRWebSocketListener.onFailure(OkHttpWebSocketWrapper.java:98)
at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:570)
at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:197)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

@hirenpatel868
Copy link
Author

@mikaelm12 there is not connectionStateChanged listener..how to get connection state changed event ...
i also facing issue of signalr disconnection at certain interval..so is there any specific setting we have to apply at both ends..? how many users at a time can connect with one signalr backend..is there any limitations for numbers of users signalr can handle ?

@mikaelm12
Copy link
Contributor

@gxh-apologize What version of the SignalR Java client are you using? And do you have websockets enabled on your back end site? Cloud providers usually have it off by default and have a toggle to turn websocket support on.

@mikaelm12
Copy link
Contributor

there is not connectionStateChanged listener..how to get connection state changed event

@hirenpatel868 In the current version of the Java client we only have two states. Connected and Disconnected. So the onClosed callback would be what you're looking for since there is no auto reconnect (we're planning to add support for that in 3.0).

@gxh-apologize
Copy link

@mikaelm12
` implementation 'com.microsoft.signalr:signalr:1.0.0
HubConnection hubConnection;
public void signalr() {
hubConnection = HubConnectionBuilder.create(url)
.build();
hubConnection.on("Send", new Action() {
@OverRide
public void invoke() {
Logger.d("gxh", "......");
}
});

    new HubConnectionTask().execute(hubConnection);

}

class HubConnectionTask extends AsyncTask<HubConnection, Void, Void> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(HubConnection... hubConnections) {
        HubConnection hubConnection = hubConnections[0];
        hubConnection.start().blockingAwait();
        return null;
    }
}

`
My code refers to demo.The server is not my responsibility.I need to ask them .thank u.

@hirenpatel868
Copy link
Author

@mikaelm12...ok i will check it out..but what about facing issue of signalr disconnection at certain interval..so is there any specific setting we have to apply at both ends..? how many users at a time can connect with one signalr backend..is there any limitations for numbers of users signalr can handle ?

@mikaelm12
Copy link
Contributor

@gxh-apologize One thing you could do is upgrade to the 3.0.0-preview3-19153-02 version. Note that it is a preview version though. But with this you can set the transport to LongPolling and see if you are able to successfully connect.

@mikaelm12
Copy link
Contributor

You would set LongPolling like this

HubConnection hubConnection = HubConnectionBuilder
    .create("http://example.com")
    .withTransport(TransportEnum.LONG_POLLING)
    .build();

@mikaelm12
Copy link
Contributor

@hirenpatel868

but what about facing issue of signalr disconnection at certain interval

Can you elaborate on this? This is not something you should be seeing normally without any special configuration.

how many users at a time can connect with one signalr backend..is there any limitations for numbers of users signalr can handle ?

This is a very application/machine specific question.

@gxh-apologize
Copy link

@mikaelm12
I can connect to my server with 3.0.0-preview3-19153-02 version . thank u .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants