我试图在谷歌应用引擎(1.9.22)上使用OKHTTP(版本2.4.0)进行改造(1.9.0).
这是我如何使用它:
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setConnectTimeout(COMPOSER_MODULE_CONNECTION_TIMEOUT, TimeUnit.SECONDS);
okHttpClient.setReadTimeout(COMPOSER_MODULE_SOCKET_TIMEOUT, TimeUnit.SECONDS);
RestAdapter restAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL)
.setConverter(new JacksonConverter())
.setEndpoint(ENDPOINT_PATH)
.setClient(new OkClient(okHttpClient))
.build();
Run Code Online (Sandbox Code Playgroud)
这会引发以下错误:
java.lang.NoClassDefFoundError: java.net.ProxySelector is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.apphosting.runtime.security.shared.stub.java.net.ProxySelector.<clinit>(ProxySelector.java)
at com.squareup.okhttp.OkHttpClient.copyWithDefaults(OkHttpClient.java:614)
at com.squareup.okhttp.Call.<init>(Call.java:50)
at com.squareup.okhttp.OkHttpClient.newCall(OkHttpClient.java:595)
at retrofit.client.OkClient.execute(OkClient.java:53)
Run Code Online (Sandbox Code Playgroud)
我从错误中收集到"java.net.ProxySelector"未列入白名单以用于google appengine.
问题1)是否可以在谷歌应用引擎(1.9.22)上使用OKHTTP(版本2.4.0)进行改造(1.9.0)?即,是否有解决此错误的方法
如果没有,问题2)还有其他方法:
(a) use async HTTP calls with google appengine (with URLFetchService, for instance) ?
(b) set connection and socket timeouts for the client used from (a) …Run Code Online (Sandbox Code Playgroud)