I am using rxjava version v-2.2.6 & naiksoftware/stompprotocolandroid v-1.6.4
I keep getting this error
java.lang.ClassNotFoundException: Class io.reactivex.functions.Action not found
anytime I add this library implementation
'com.github.NaikSoftware:StompProtocolAndroid:1.5.2'
to my build.gradle
file, why is this ?
public void connectStomp(View view) {
List<StompHeader> headers = new ArrayList<>();
headers.add(new StompHeader(LOGIN, "guest"));
headers.add(new StompHeader(PASSCODE, "guest"));
//mStompClient.withClientHeartbeat(10000).withServerHeartbeat(10000);
resetSubscriptions();
Disposable dispLifecycle = mStompClient.lifecycle()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(lifecycleEvent -> {
switch (lifecycleEvent.getType()) {
case OPENED:
Log.e(TAG, "Stomp connection opened");
//toast("Stomp connection opened");
break;
case ERROR:
Log.e(TAG, "Stomp connection error", lifecycleEvent.getException());
//toast("Stomp connection error");
mStompClient.reconnect();
break;
case CLOSED:
Log.e(TAG, "Stomp connection closed");
mStompClient.disconnect();
resetSubscriptions();
//toast("Stomp connection closed");
// mStompClient.connect();
break;
case FAILED_SERVER_HEARTBEAT:
Log.e(TAG, "Stomp connection opened");
//toast("Stomp failed server heartbeat");
break;
}
}, throwable -> {
Log.e(TAG, "Error on subscribe topic", throwable);
});
compositeDisposable.add(dispLifecycle);
// Receive greetings
Disposable dispTopic = mStompClient.topic("/topic/greetings")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.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(headers);
}
NaikSoftware/StompProtocolAndroid library is not using updated code, i had faced similar issue while integrating stomp client in android.
Refer below repository for the solution, replace the server-url and port number with you custom port and server-url.
repo- https://github.com/NaikSoftware/StompProtocolAndroid
Let me know if it solves your issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.