Matthias247 / jawampa

Web Application Messaging Protocol (WAMP v2) support for Java
Apache License 2.0
148 stars 56 forks source link

Jawampa crashes when connections is closed. #97

Closed rprunskas closed 7 years ago

rprunskas commented 7 years ago

Hi, when app executes logout procedure, server closes the connection and jawampa crashes, do you have any idea why that is happening?

12-13 09:37:27.391 15911-15911/lv.ossnet.smartmex E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: lv.ossnet.smartmex, PID: 15911
                                                                    java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
                                                                        at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
                                                                        at android.os.Handler.handleCallback(Handler.java:733)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:146)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5602)
                                                                        at java.lang.reflect.Method.invokeNative(Native Method)
                                                                        at java.lang.reflect.Method.invoke(Method.java:515)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
                                                                        at dalvik.system.NativeStart.main(Native Method)
                                                                     Caused by: java.util.concurrent.RejectedExecutionException: event executor terminated
                                                                        at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:745)
                                                                        at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:322)
                                                                        at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:728)
                                                                        at io.netty.util.concurrent.AbstractEventExecutorGroup.execute(AbstractEventExecutorGroup.java:114)
                                                                        at ws.wamp.jawampa.client.SessionEstablishedState$6.call(SessionEstablishedState.java:676)
                                                                        at rx.subscriptions.BooleanSubscription.unsubscribe(BooleanSubscription.java:72)
                                                                        at rx.internal.util.SubscriptionList.unsubscribeFromAll(SubscriptionList.java:124)
                                                                        at rx.internal.util.SubscriptionList.unsubscribe(SubscriptionList.java:113)
                                                                        at rx.Subscriber.unsubscribe(Subscriber.java:98)
                                                                        at rx.internal.util.SubscriptionList.unsubscribeFromAll(SubscriptionList.java:124)
                                                                        at rx.internal.util.SubscriptionList.unsubscribe(SubscriptionList.java:113)
                                                                        at rx.Subscriber.unsubscribe(Subscriber.java:98)
                                                                        at 

rx.observers.SafeSubscriber.onCompleted(SafeSubscriber.java:90)
                                                                        at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:201)
                                                                        at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:170)
                                                                        at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
                                                                        at android.os.Handler.handleCallback(Handler.java:733) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                        at android.os.Looper.loop(Looper.java:146) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5602) 
                                                                        at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                        at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
                                                                        at dalvik.system.NativeStart.main(Native Method) 
Matthias247 commented 7 years ago

Something tries to use the underlying scheduler (from Netty) for queuing a callback while this has already been shut down. That should normally not happen, since the scheduler only shuts down after a certain grace period (to assert that no further callbacks are queued). Is this happening in debugger mode? If the application is stopped in one thread it can happen that that the background thread already shuts down and when the other thread is resumed and tries to queue something a similar exception will happen.

Apart from that I have no direct idea. It would be required to check the states and events that lead to this event.

rprunskas commented 7 years ago

Yes, I'm using debug mode. I checked what is happening when connection is closed from the server.

Client reveices error - wamp.error.goodbye_and_out, then it tries to clear session data, so it goes over subscriptions. At the same time StateController method setState() is called while client tries to unsubscribe from all the subscriptions. So, that shutdowns SingleThreadEventExecutor which is used to unsubscribe and then this crash occurs. Why shutdown happens in the middle of unsubscribing?

Matthias247 commented 7 years ago

This should hopefully be fixed in the just uploaded 0.5.0 version. If it still happens and anyone can give some clues (or even bugfixes), please open a new issue or PR: