title: java.net.SocketException: Socket closed not caught by RxJava onError (Single)
body: <p>I am doing something like this: in my <code>Fragment</code>, I am observing a <code>LiveData</code> exposed by a <code>ViewModel</code> that encapsulates different UI states like error, loading, success state, etc. Within the said <code>ViewModel</code>, I start an RxJava2 stream that kicks off a chain of REST API requests via Retrofit:</p>
  <pre><code>    public LiveData&lt;UIState&gt; doSomething() {
          compositeDisposable.add(somethingRepo.doA()
              .andThen(somethingRepo.doB())
              .andThen(somethingRepo.doC())
              .subscribeOn(Schedulers.io())
              .observeOn(AndroidSchedulers.mainThread())
              .doOnSubscribe(disposable -&gt; status.setValue(UIState.LOADING()))
              .subscribe(() -&gt; status.setValue(UIState.SUCCESS()), error -&gt; {
                  Log.d(&quot;SettingsVM&quot;, &quot;error: &quot; + error.getClass().getSimpleName());
  
                  if(error instanceof VersionAlreadyExistsException) {
                      status.setValue(UIState.VERSION_EXISTS());
                  } else {
                      status.setValue(UIState.ERROR(error.getMessage()));
                  }
              })
          );
          return status;
      }
  </code></pre>
  <p>However, according to my custom logger that implements <code>HttpLoggingInterceptor.Logger</code>, I am getting a <code>java.net.SocketException: Socket closed</code> during <code>somethingRepo.doA()</code>, but it seems that I am not getting the Exception in <code>doSomething()</code>'s <code>onError</code>. Here is the full <code>somethingRepo.doA()</code>:</p>
  <pre><code>public Completable doA() {
      return api.doRequest(paramRepository.getUrl(false),
          paramRepository.getAuthorization(),
          paramRepository.getName())
          .flatMapCompletable(requestResponse-&gt; {
              if(paramRepository.getVersion().contentEquals(requestResponse.getVersion())) {
                  return Completable.error(new VersionAlreadyExistsException());
              } else {
                  return Completable.complete();
              }
          });
  }
  </code></pre>
  <p>api.doRequest is a <code>GET</code> request that looks like this:</p>
  <pre><code>@GET
  Single&lt;RequestResponse&gt; doRequest (
          @Url String url,
          @Header(&quot;authorization&quot;) String authorization,
          @Query(&quot;merch&quot;) String name);
  </code></pre>
  <p>Interestingly, on another Android app, I sent a <code>POST</code> to the same URL I am using in the previous example and what I got was <code>HTTP FAILED: java.net.ConnectException: Failed to connect to /180.232.98.122:7443</code>.</p>
  <p>I am aware of a similar <a href="https://github.com/square/retrofit/issues/2708" rel="nofollow noreferrer">issue</a> being opened in the official Retrofit repo and a similar SO question <a href="https://stackoverflow.com/questions/44324941/socketexception-unsubscribing-request-without-onerror">here</a>, but those two are unresolved, thus I would like to hear if anyone here has encountered the same behavior.</p>