title: Problems after override SocketFactory with OkHttp
body: <p>I was having troubles with https request after update my app to api 21. After a deep code review I found a funny bug.</p>
  
  <p>My app has been compiled with api-21 now, and this api has a new version of okHttp inside the sdk, version 2.2.0. The old version of the app used the version of okHttp 2.0.0.</p>
  
  <p>With the version 2.2.0 I have an exception when I try open a new https request. the exception is:</p>
  
  <pre><code>java.net.SocketException: Unconnected sockets not implemented
          at javax.net.SocketFactory.createSocket(SocketFactory.java:64)
          at com.squareup.okhttp.Connection.connect(Connection.java:144)
          at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:169)
          at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:119)
          at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:134)
          at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:314)
          at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:237)
          at com.squareup.okhttp.Call.getResponse(Call.java:233)
          at com.squareup.okhttp.Call.execute(Call.java:84) 
  </code></pre>
  
  <p>The problem is okHttp changed the way that Connection class works on version 2.1.0. On version 2.0.0 the connection create a new plain Socket directly but know the request this socket to the socket factory this socket will be upgrade to a TLS. The change is:</p>
  
  <pre><code>socket = route.address.socketFactory.createSocket();
  </code></pre>
  
  <p>My problem is that I have overrited the socketFactory for NotHttpSocketFactory, and this implementation does nothing (it's ok, you want remove http connections) and the method createSocket(), has not been overrited. I dont like allow http requests.</p>
  
  <p>And I override the SocketFactory.</p>
  
  <pre><code>client.setSocketFactory(new BlackphoneStubSocketFactory());
  </code></pre>
  
  <p>I don't understand why I need a plain socket, with I'm creating a https requests. Is this necessary? I can override the method createSocket() and return an empty socket, but it is necessary or it is a bug on OkHttp.</p>