【发布时间】:2015-09-03 21:29:16
【问题描述】:
我正在尝试在谷歌应用引擎 (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();
这会引发以下错误:
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)
我从错误中得知“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) ?
我通过搜索找到的链接: (1)Retrofit timeout configuration for clients (2)Google App Engine URL Fetch Java API
【问题讨论】:
标签: google-app-engine retrofit okhttp