boumba100 / android-stomp-websocket

Android STOMP client library via websocket connection
11 stars 2 forks source link

io.reactivex.exceptions.OnErrorNotImplementedException: #4

Open testGumar opened 5 years ago

testGumar commented 5 years ago

Hi I am getting below error while integrating this library and executing code in device. Note: App is getting crashed just after opening the connection with the server. Not able to understand why? Already implemented doError and throwable callback in onSubscribe.

code goes like that =----------- mStompClient = Stomp.over(Stomp.ConnectionProvider.OKHTTP, "ws://fuelware-env.mkp8vm63pa.ap-south-1.elasticbeanstalk.com:6614/stomp");

    mStompClient.withClientHeartbeat(1000).withServerHeartbeat(1000);

    Disposable dispLifecycle = mStompClient.lifecycle()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnError(throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))
            .subscribe(lifecycleEvent -> {
                switch (lifecycleEvent.getType()) {
                    case OPENED:
                        //MLog.showToast(this, "Stomp connection opened");
                        Log.e(TAG, "Stomp connection opened");
                        break;
                    case ERROR:
                        Log.e(TAG, "Stomp connection error", lifecycleEvent.getException());
                        //MLog.showToast(this, "Stomp connection error");
                        break;
                    case CLOSED:
                        //MLog.showToast(this, "Stomp connection closed");
                        break;
                    case FAILED_SERVER_HEARTBEAT:
                        //MLog.showToast(this, "Stomp  failed server heartbeat");
                        break;
                }
            }, throwable -> {
                Log.e(TAG, "Error on subscribe topic", throwable);
            });

    compositeDisposable.add(dispLifecycle);

    // Receive greetings
    Disposable dispTopic = mStompClient.topic("/topic/6jrllu01nnmiz0xep6ic")
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnError(throwable -> Log.e(TAG, "Throwable " + throwable.getMessage()))
            .subscribe(topicMessage -> {
                Log.d(TAG, "Received " + topicMessage.getPayload());
                //addItem(mGson.fromJson(topicMessage.getPayload(), EchoModel.class));
            }, throwable -> {
                Log.e(TAG, "Error on subscribe topic", throwable);
            });

    compositeDisposable.add(dispTopic);

    mStompClient.connect();

Error goes like that --------------

E/AndroidRuntime: FATAL EXCEPTION: OkHttp http://fuelware-env.mkp8vm63pa.ap-south-1.elasticbeanstalk.com:6614/... Process: com.ouhmac.fwcashier, PID: 6118 io.reactivex.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | java.util.NoSuchElementException

Vikrant-Kunwar commented 4 years ago

Did you find any solution to this problem @SayyedUmar

ahmad3ttallah commented 4 years ago

Any updates about that issue?

ahmad3ttallah commented 4 years ago

In the method: ua.naiksoftware.stomp.dto.StompMessage#from For the version StompProtocolAndroid:1.6.4 there is line reader.skip("\n\n"); That was firing the exception Changed to the version the version StompProtocolAndroid:1.6.3 The line is reader.skip("\\s"); And that worked fine with me. For me the STOMP server is implemented using Sprinboot