SignalR negotiate method calling in loop sometimes in 24 hours

325 Views Asked by At

I have used below code to connect with hub.

Its working proper. but sometime suddenly the negotiate GET method calls thousands of time.

private HubConnection createLocalHubConnection() {
    if (Common.isInternetAvailable(CallObserverTestService.this)) {
        Log.i(TAG, "Create Connection");
        final HubConnection loConnection = new HubConnection(WebService.getHubURL(CallObserverTestService.this));
        Log.i(TAG, "Connection State1: " + loConnection.getState());
        if (loConnection.getState() == ConnectionState.Disconnected) {
            moProxy = loConnection.createHubProxy(CallObserverTestService.this.getString(R.string.hub));
            try {
                loConnection.stop();
                loConnection.start().done(new Action<Void>() {
                    @Override
                    public void run(Void obj) throws Exception {
                        Log.i(TAG, "Connection URL: " + loConnection.getUrl());
                        Log.i(TAG, "SignalR ConnectionId: " + loConnection.getConnectionId());
                    }
                }).onError(new ErrorCallback() {
                    @Override
                    public void onError(Throwable error) {
                        Log.i(TAG, "SignalR: onError : " + error.getMessage());
                        error.printStackTrace();
                        Log.logException(TAG, error);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                Log.logException(TAG, e);
            }
        }
        return loConnection;
    }
    return null;
}

The error is as below while calling in loop

Negotiation error: There was a problem in the negotiation with the server

negotiate: https://MyDomain/signalr/negotiate?clientProtocol=1.3&connectionData=%5B%7B%22name%22%3A%22MyHubName%22%7D%5D

Reference link: https://github.com/SignalR/java-client/tree/master/signalr-client-sdk

0

There are 0 best solutions below