title: Unable to parse TLS packet header android studio
body: <p>I want to connect my local server and get some data with <strong>Retrofit</strong> but I gave the error &quot;Unable to parse TLS packet header&quot; and I couldn't solve this problem please give me a solution</p>
  <blockquote>
  <p>onFailure: Unable to parse TLS packet header</p>
  </blockquote>
  <p>ServiceBuilder.kt</p>
  <pre><code>object ServiceBuilder {
      private val client = OkHttpClient.Builder()
          .connectionSpecs(listOf(ConnectionSpec.MODERN_TLS) )
          .build()
  
      private val retrofit = Retrofit.Builder()
          .baseUrl(Config().BASE_URL)# &quot;https://10.0.2.2:5000&quot;
          .addConverterFactory(GsonConverterFactory.create())
          .client(client)
          .build()
  
      fun&lt;T&gt; buildService(service: Class&lt;T&gt;): T{
          Security.insertProviderAt(Conscrypt.newProvider(), 1);
          return retrofit.create(service)
      }
  }
  </code></pre>
  <p>LinesrsEndpoint.kt</p>
  <pre><code>interface LinesrsEndpoint{
      @GET(&quot;/getAllLinesrs&quot;)
      fun getLinesrs(): Call&lt;AllLinesrs&gt;
  }
  </code></pre>
  <p>LinesRs.kt</p>
  <pre><code>data class AllLinesrs(val results:List&lt;Linesrs&gt;)
  
  data class Linesrs(
      var lineId: Int,
      var symbolId: String,
      var lineStart: String,
      var lineEnd: String,
      var lineTimeFrame: String,
      var lineInsertTime: String,
      var lineSensDgre: String,
      var linesrsGroupId: String,
      var userId: String,
      var user: User
  
  )
  </code></pre>
  <p>MainActivity.kt</p>
  <pre><code>class MainActivity: AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_add_trend_line)
  
          val request = ServiceBuilder.buildService(LinesrsEndpoint::class.java)
          val call = request.getLinesrs()
  
          call.enqueue(object : Callback&lt;AllLinesrs&gt; {
              override fun onResponse(call: Call&lt;AllLinesrs&gt;, response: Response&lt;AllLinesrs&gt;) {
                  if (response.isSuccessful) {
                      Log.e(&quot;hamid&quot;, &quot;onResponse: &quot;+response.body() )
                  }
              }
  
              override fun onFailure(call: Call&lt;AllLinesrs&gt;, t: Throwable) {
                  Log.e(&quot;hamid&quot;, &quot;onFailure: &quot; + t.message)
              }
          })
      }
  
  }
  </code></pre>