question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OnErrorNotImplementedException in StompClient.java

See original GitHub issue

First off, thank you to everyone who works on this awesome project it really works well and is extremely useful.

I may have found a bug. Hopefully this has not been posted about and answered already, I tried to read all of the existing Issues and didn’t see this exact issue.

First, some background: I have seen the OnErrorNotImplementedException like other users:

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

…and after reading through the other issues posted and Stack Overflow I have fixed it by adding an error handler to my code that calls subscribe(), like so:

        // begin topic subscription for user data
        stompClient.topic(TOPIC_NAME_HERE)
            .doOnError(throwable -> {
                // log the error and tell the service to resubscribe
            })
            .subscribeOn(Schedulers.io())
            .subscribe(new Subscriber<StompMessage>() {
                @Override
                public void onSubscribe(Subscription subscription) {
                }

                @Override
                public void onNext(StompMessage topicMessage) {
                    // handle the incoming message
                }

                @Override
                public void onError(Throwable error) {
                    Log.e(TAG, "Error on user data topic", error);
                    resubscribe = true;
                }

                @Override
                public void onComplete() {
                }
            });

This made the crashes extremely rare. With the help of the debugger I found that crashes would still happen occasionally when using the StompClient to use heartbeat messages inside the StompClient’s connect method. In that method the subscribe call is made but no error handler is specified. When I initially connect the StompClient and setup heartbeating (via stompClient.withClientHeartbeat(1000).withServerHeartbeat(1000);) I see the error occur after I call stompClient.disconnect(). I think this is because there is an error that is not handled.

I might have totally missed something… If this is a legit issue would be happy to add the error handlers to the StompClient connect() method code and create a PR if it helps.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joshuajwittercommented, Sep 25, 2019

It works after I added this line.

    stompClient.setPathMatcher(ActivePathMatcher());

I had to make some changes to the library locally

:trollface:

1reaction
forresthopkinsacommented, Sep 19, 2019

If you’re starting a new project, don’t use this legacy library. Use tinder/scarlet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Where I may wrong while connected to StompClient?
I used the same Library in order to connect with Stomp based web socket. There were some configurations on the server side.
Read more >
RxJava: OnErrorNotImplementedException - Sangsoo Nam
RxJava(Reactive Extensions for the JVM) is a library for event-based programs. It allows composing asynchronous easily.
Read more >
README optimserver-client-stomp - IBM
Stomp client library based on 'org.java-websocket:Java-WebSocket' (provided for a lighter implementation; use of client-stomp-spring is recommended). Can be ...
Read more >
Using Spring Boot for WebSocket Implementation with STOMP
In this article, Toptal Freelance Java Developer Tomasz Dąbrowski shows us how to ... Spring Java's STOMP client allows to set headers for...
Read more >
A Java Client for a WebSockets API - Baeldung
Learn how to use Spring to implement a Java client to consume a WebSockets ... stompClient = new WebSocketStompClient(client); stompClient.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found