改造2 - 延迟响应

时间:2016-10-07 10:50:40

标签: android retrofit2 activesync

我在改造时遇到问题2.我正在向Microsoft EAS服务器发送一些数据,但是在20秒后收到响应。为什么我知道这是一个改装问题?因为没有改造它可以正常工作。

我的日志:

D/OkHttp: --> POST https://{my_host}/Microsoft-Server-ActiveSync?Cmd=Provision&User={myuser}&DeviceId=837bc6c5690b40b98ab55f7a2231e50c&DeviceType={mydevicetype} http/1.1
D/OkHttp: Content-Type: application/vnd.ms-sync.wbxml
D/OkHttp: Content-Length: 456
D/OkHttp: Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
D/OkHttp: MS-ASProtocolVersion: 14.1
D/OkHttp: Connection: keep-alive
D/OkHttp: User-Agent: MyUserAgent
D/OkHttp: X-MS-PolicyKey: 0
D/OkHttp: [3,1,106,0,0,14,[...more here...],88,77,76,0,1,1,1,1] // <--- body
D/OkHttp: --> END POST (456-byte body)

20秒后(似乎我收到20 +正常接收时间后的响应 - 在这种情况下:20596ms):

D/OkHttp: <-- 200 OK https://{my_host}/Microsoft-Server-ActiveSync?Cmd=Provision&User={myuser}&DeviceId=837bc6c5690b40b98ab55f7a2231e50c&DeviceType={mydevicetype}  (20596ms)
D/OkHttp: Content-Type: application/vnd.ms-sync.wbxml
D/OkHttp: request-id: {request_id}
D/OkHttp: Set-Cookie: {cookie_data}
D/OkHttp: X-CalculatedBETarget: {target}.local
D/OkHttp: X-MS-BackOffDuration: L/-470
D/OkHttp: X-DiagInfo: EXCHANGEHA
D/OkHttp: X-BEServer: EXCHANGEHA
D/OkHttp: Set-Cookie: {cookie_data}
D/OkHttp: X-FEServer: EX01
D/OkHttp: Date: Fri, 07 Oct 2016 10:30:08 GMT
D/OkHttp: <-- END HTTP (binary 15-byte body omitted)

如果我在没有改装的情况下请求它,它会立即向我发送回复。

我的代码:

初始化:

OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
        httpClient.addInterceptor(chain -> {
            Request original = chain.request();

            Request.Builder requestBuilder = original.newBuilder()
                    .addHeader("Authorization", getAuth(account))
                    .addHeader("MS-ASProtocolVersion", getProtocolVersion())
                    .addHeader("Connection", getConnectionType())
                    .addHeader("User-Agent", getUserAgent())
                    .addHeader("X-MS-PolicyKey", getPolicyKey());

            Request request = requestBuilder.build();
            return chain.proceed(request);
        });
        if (EasConfig.isDebug()) {
            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            logging.setLevel(HttpLoggingInterceptor.Level.BODY);
            httpClient.addInterceptor(logging);
        }

        httpClient.readTimeout(30, TimeUnit.SECONDS);
        httpClient.writeTimeout(30, TimeUnit.SECONDS);

        OkHttpClient client = httpClient.build();

        retrofit = new Retrofit.Builder()
                .baseUrl(getBaseUrl(account))
                .addConverterFactory(GsonConverterFactory.create())
                .client(client)
                .build();

呼叫:

ActiveSyncService service = retrofit.create(ActiveSyncService.class);
service.getData(getContentType(), command, getUser(account), getDeviceId(), getUserAgent(), serializer.toByteArray());

端点:

@POST("Microsoft-Server-ActiveSync")
Call<ResponseBody> getData(@Header("Content-Type") String contentType, // <--- it has to be here -- it's not woking if I set it in incerteptor (don't know why)
                           @Query("Cmd") String command,
                           @Query("User") String user,
                           @Query("DeviceId") String deviceId,
                           @Query("DeviceType") String deviceType,
                           @Body byte[] data);

0 个答案:

没有答案