title: FATAL EXCEPTION: During Retrofit network request : Kotlin Coroutine
body: <p>I am getting a Fatal exception while making an API call using co-routine and retrofit in android kotlin. And app crashes with below exception.</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-7
  Process: com.jamhub.barbeque, PID: 18525
  java.net.SocketTimeoutException: timeout
      at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:656)
      at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:664)
      at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:153)
      at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131)
      at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
      at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
      at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
      at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
      at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
  </code></pre>
  
  <p>Tried adding time out, CoroutineExceptionHandler</p>
  
  <pre><code>val client = OkHttpClient().newBuilder().addInterceptor(object : Interceptor {
                      override fun intercept(chain: Interceptor.Chain): Response {
                          val request = chain.request()
                              .newBuilder()
                              .build()
                          return chain.proceed(request)
                      }
                  }).callTimeout(30, TimeUnit.SECONDS)
                      .connectTimeout(10, TimeUnit.SECONDS)
                      .writeTimeout(10, TimeUnit.SECONDS)
                      .readTimeout(30, TimeUnit.SECONDS)
                      .build()
  
                  retrofitSocial = Retrofit.Builder()
                      .baseUrl(BuildConfig.BASE_URL)
                      .addConverterFactory(GsonConverterFactory.create())
                      .client(client)
                      .build()
  </code></pre>
  
  <p>It shouldn't crash if the exception has occurred ideally it should return the request failure.</p>