{"action":"created","issue":{"url":"https://api.github.com/repos/square/okhttp/issues/2453","repository_url":"https://api.github.com/repos/square/okhttp","labels_url":"https://api.github.com/repos/square/okhttp/issues/2453/labels{/name}","comments_url":"https://api.github.com/repos/square/okhttp/issues/2453/comments","events_url":"https://api.github.com/repos/square/okhttp/issues/2453/events","html_url":"https://github.com/square/okhttp/issues/2453","id":144908254,"number":2453,"title":"[Question] Proxy connection always fail with unexpected end of stream.","user":{"login":"smatei","id":17740806,"avatar_url":"https://avatars.githubusercontent.com/u/17740806?v=3","gravatar_id":"","url":"https://api.github.com/users/smatei","html_url":"https://github.com/smatei","followers_url":"https://api.github.com/users/smatei/followers","following_url":"https://api.github.com/users/smatei/following{/other_user}","gists_url":"https://api.github.com/users/smatei/gists{/gist_id}","starred_url":"https://api.github.com/users/smatei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smatei/subscriptions","organizations_url":"https://api.github.com/users/smatei/orgs","repos_url":"https://api.github.com/users/smatei/repos","events_url":"https://api.github.com/users/smatei/events{/privacy}","received_events_url":"https://api.github.com/users/smatei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-03-31T13:50:57Z","updated_at":"2016-04-01T07:09:33Z","closed_at":null,"body":"Hi,\r\n\r\nOn some proxies (squid proxy) OKHttpClient works well. On others (also squid proxies), for an unknown reason, I **always** get the **\"unexpected end of stream**\" error (Caused by: java.io.EOFException: \\n not found: size=0 content). For all the browsers and other http clients (java, apache, jetty), the proxy works. \r\n\r\n`Exception in thread \"main\" java.io.IOException: unexpected end of stream\r\n\tat okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:215)\r\n\tat okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)\r\n\tat okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:732)\r\n\tat okhttp3.internal.http.HttpEngine.access$2(HttpEngine.java:726)\r\n\tat okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:714)\r\n\tat okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:566)\r\n\tat okhttp3.RealCall.getResponse(RealCall.java:245)\r\n\tat okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:200)\r\n\tat okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:162)\r\n\tat okhttp3.RealCall.execute(RealCall.java:59)\r\n\tat testok.run(testok.java:54)\r\n\tat testok.main(testok.java:61)\r\nCaused by: java.io.EOFException: \\n not found: size=0 content=...\r\n\tat okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)\r\n\tat okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:191)\r\n\t... 11 more`\r\n\r\nI have tried to debug it using the OKHttp and okio sources, by sniffing with Wireshark, but no luck. Somehow the server response is missing. How can I debug this?\r\n\r\nThe code that I use is quite simple.\r\n\r\n`    Authenticator proxyAuthenticator = new Authenticator() {\r\n      public Request authenticate(Route route, Response response) throws IOException {\r\n           String credential = Credentials.basic(user, password);\r\n           return response.request().newBuilder()\r\n               .header(\"Proxy-Authorization\", credential)\r\n               .build();\r\n      }\r\n    };\r\n    \r\n    OkHttpClient client = new OkHttpClient.Builder()\r\n        .protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1, Protocol.SPDY_3))\r\n        .connectTimeout(60, TimeUnit.SECONDS)\r\n        .writeTimeout(60, TimeUnit.SECONDS)\r\n        .readTimeout(60, TimeUnit.SECONDS)\r\n        .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy, port)))\r\n        .proxyAuthenticator(proxyAuthenticator)\r\n        .authenticator(proxyAuthenticator)\r\n        .build();\r\n    \r\n    Request request = new Request.Builder()\r\n        .url(url)\r\n        .header(\"User-Agent\", \"Mozilla/5.0 (Windows NT 6.2; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0\")\r\n        .build();\r\n\r\n    Response response = client.newCall(request).execute();\r\n    System.out.println(\"response \" + response.code());\r\n    return response.body().string();`\r\n\r\nBest Regards,\r\nStefan Matei\r\n "},"comment":{"url":"https://api.github.com/repos/square/okhttp/issues/comments/204278648","html_url":"https://github.com/square/okhttp/issues/2453#issuecomment-204278648","issue_url":"https://api.github.com/repos/square/okhttp/issues/2453","id":204278648,"user":{"login":"smatei","id":17740806,"avatar_url":"https://avatars.githubusercontent.com/u/17740806?v=3","gravatar_id":"","url":"https://api.github.com/users/smatei","html_url":"https://github.com/smatei","followers_url":"https://api.github.com/users/smatei/followers","following_url":"https://api.github.com/users/smatei/following{/other_user}","gists_url":"https://api.github.com/users/smatei/gists{/gist_id}","starred_url":"https://api.github.com/users/smatei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smatei/subscriptions","organizations_url":"https://api.github.com/users/smatei/orgs","repos_url":"https://api.github.com/users/smatei/repos","events_url":"https://api.github.com/users/smatei/events{/privacy}","received_events_url":"https://api.github.com/users/smatei/received_events","type":"User","site_admin":false},"created_at":"2016-04-01T07:09:33Z","updated_at":"2016-04-01T07:09:33Z","body":"For https I need the Proxy-Authorization header in the RealConnection.createTunnelRequest method."}}