jacek-marchwicki / javawebsocketclient Goto Github PK
View Code? Open in Web Editor NEWRxJava WebSocket library for Java and Android
RxJava WebSocket library for Java and Android
Thanks for this awesome Rx support. I need help in understanding how do I implement WebSockets so that it only lives for the Application Lifecycle.
I create a subscription in onCreate()
of Application and unsubscribe in onDestroy()
Should I manage this subscription from an IntentService or if you have any other suggestions please let me know.
I also thought about implementing Sockets through GCMNetworkManager and manage subscription in this GCM task, but not sure if it's feasible or fit's my use case.
Please can you guide me in a correct direction
When RxJava 2 support will be implemented?
Using https://pypi.python.org/pypi/seqdiag/ and script that parse logs we can create tool that convert whole connection to pretty diagram
It would be better if we create a docker image for websocket server
Deploy it to our cluster to have a always running websocket server as an example
Seeing some crash reports from users with stacktrace below. Odd because I thought this issue was fixed awhile back with OkHttp. Might be due to the fact that OkHttp-ws is still experimental.
This problem can be solved by setting unsubcribeOn()
to a background thread for meantime.
Fatal Exception: java.lang.RuntimeException: Unable to pause activity: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4379)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4338)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4313)
at android.app.ActivityThread.access$1200(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:855)
at okio.Okio$1.write(Okio.java:80)
at okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
at okio.RealBufferedSink.emit(RealBufferedSink.java:183)
at okhttp3.internal.ws.WebSocketWriter.writeControlFrameSynchronized(WebSocketWriter.java:152)
at okhttp3.internal.ws.WebSocketWriter.writeClose(WebSocketWriter.java:111)
at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:168)
at com.appunite.websocket.rx.RxWebSockets$LockingWebSocket.close(RxWebSockets.java:209)
at com.appunite.websocket.rx.RxWebSockets$1$2.call(RxWebSockets.java:163)
at rx.subscriptions.BooleanSubscription.unsubscribe(BooleanSubscription.java:71)
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.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.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.subscriptions.SerialSubscription.unsubscribe(SerialSubscription.java:66)
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 com.domain.interactor.UseCase.unsubscribe(UseCase.java:36)
at com.ui.playback.PlaybackPresenter.onPause(PlaybackPresenter.java:61)
at com.ui.templates.BaseFragmentListener.onPause(BaseFragmentListener.java:80)
at android.support.v4.app.Fragment.performPause(Fragment.java:2139)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1117)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
at android.support.v4.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:2060)
at android.support.v4.app.FragmentController.dispatchPause(FragmentController.java:207)
at android.support.v4.app.FragmentActivity.onPause(FragmentActivity.java:443)
at com.ui.templates.BaseActivity.onPause(BaseActivity.java:47)
at android.app.Activity.performPause(Activity.java:6706)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1324)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4365)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4338)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4313)
at android.app.ActivityThread.access$1200(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
In your implementation on each subscribe creates a new websocket connection. Do you fix this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.