ioexception


How to cancel request using merge


Actually I am using RxAndroid, Retrofit2.0 and Okhttp 3.2.0 in my project.
I am using Observable.merge to call multiple request in order to upload files.
Is there any solution to cancel a unique request ? I know I could use subscription.unsubscribe() but it will cancel all tasks.
I Used okhttp method like client.dispatcher.get(0).cancel() but it throw me an Io Exception like Canceled and it will cancel all tasks.
Do you have a proper way to cancel only a selected request ? Thank you
You could attach use a takeUntil(Observable a) to each of your constituent Observables and use the "control" observable to selective cancel them. For example
PublishSubject<Object> control1 = PublishSubject.create();
PublishSubject<Object> control2 = PublishSubject.create();
Observable<T> cancellableRestrofitObservable1 = retrofitObservable1.takeUntil(control1.asObservable());
Observable<T> cancellableRestrofitObservable2 = retrofitObservable2.takeUntil(control2.asObservable());
Observable<T> mergedObservable = Observable.merge(cancellableRestrofitObservable1,cancellableRestrofitObservable2);
// To cancel retrofitObservable1
control1.onNext("cancel");
It's working well. This is the code:
PublishSubject control = PublishSubject.create();
publishSubjectMap.put(position, control);
Observable<Response<Upload>> cancellableRestrofitObservable = dropboxapi.uploadImage(requestBody, params, position)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.takeUntil(control.asObservable());
observables.add(cancellableRestrofitObservable);
Observable<Response<Upload>> mergedObservable = Observable.merge(observables);
//To cancel
publishSubjectMap.get(event.getPosition()).onNext("cancel");

Related Links

java.io.IOException: Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured
How to cancel request using merge
PrintWriter doesn't seem to be writing to file even though I'm closing it
StreamWriter.Writeline throws “Not enough storage is available to process this command.” IO exception
IO Exception in OSMembrane while executing pipeline
Exception in thread Main Error java.lang.numberformat.exception
java.io.IOException: The filename, directory name, or volume label syntax is incorrect Error while writing to HTTP directory

Categories

HOME
artificial-intelligence
libgdx
qc
operating-system
braintree
iverilog
semantic-web
tabs
tcp
linker
ui-automation
minecraft
eddystone
mutation-testing
gtk
fireloop
django-rq
orange-api
async-await
closures
asciimath
varnish-vcl
string-formatting
boomi
renderscript
cmake-gui
yii2-basic-app
coreldraw
sybase-ase
basex
math.js
miniprofiler
commonsware-cwac
buildforge
testlink
android-alarms
assemblies
classnotfoundexception
dagger
notesview
audio-converter
music21
section508
viewmodel
sony-future-lab-n
brightscript
subforms
webvtt
scala-collections
apache-modules
emacs25
ltrace
instafeedjs
cocoa-bindings
dcount
data-management
right-to-left
android-syncadapter
maximize
univocity
ioctl
django-validation
ibm-was
arbre
sqlbase
enaml
libz
angular-amd
subfolder
string.format
wicket-1.5
neo4jphp
sqlbindparameter
iosched
autonumber
mft
vlab
stty
codahale-metrics
sunstudio
xs
proc-open
daap
gitx
struts2-json-plugin
zend-pdf
audiotoolbox
algol68
wcf-callbacks
kolite
n-queens
drawimage
getopts
mongrel
raw-data
acceleration

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App