retrofit2 패치 요청이 본문으로 응답하지 않음

하메드

일부 엔드 포인트가있는 애플리케이션에서 작업 중입니다. 요약하면 본문을 채울 때 패치 요청이 콜백하지 않고 시간 초과 오류가 발생합니다. 이 이벤트는 패치 요청에 대해서만 발생하며 GET, POST, PUT 및 DELETE와 같은 다른 방법이 제대로 작동합니다. 다른 것은 이러한 엔드 포인트가 모두 Postman에서 잘 작동한다는 것입니다.

내 서비스 중 하나

public interface ApiService {

    @Headers({"Accept: application/json;version=0.1.1",
            "Content-Type: application/json; charset=utf-8"})
    @PATCH("api/club/product/{id}/")
    Call<ResponseBody> requestEditProducts(@Header ("Authorization") String token,
                                           @Body RequestBody body,
                                           @Path("id") int id);
}

클라이언트 클래스

public class RetrofitClient {

    private static Retrofit retrofit = null;

    public static Retrofit getInstance() {
        if (retrofit == null) {

            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            logging.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
            httpClient.addInterceptor(logging);
            httpClient.connectTimeout(120, TimeUnit.SECONDS);
            httpClient.callTimeout(120, TimeUnit.SECONDS);
            httpClient.readTimeout(120, TimeUnit.SECONDS);
            httpClient.writeTimeout(120, TimeUnit.SECONDS);
            httpClient.retryOnConnectionFailure(true);

            retrofit = new Retrofit.Builder()
                    .baseUrl(Consts.BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .client(httpClient.build())
                    .build();
        }
        return retrofit;
    }
}

하나의 통화 예

JSONObject object = new JSONObject();
        try {
            object.put("name", "new name");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), object.toString());

        Call<ResponseBody> call = RetrofitClient.getInstance().create(ApiService.class)
                .requestEditProducts(token, requestBody, id);
        call.enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                Log.d("PATCH_REQUEST", "code: " + response.code() +
                        "             body: " + response.body());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
                t.printStackTrace();
            }
        });

원콜 결과

D/OkHttp: --> PATCH http://beta.nsme.com/api/club/product/9/
D/OkHttp: Content-Type: application/json; charset=utf-8
D/OkHttp: Content-Length: 41
D/OkHttp: Accept: application/json;version=0.1.1
D/OkHttp: Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxx
D/OkHttp: {"name":"new name"}
D/OkHttp: --> END PATCH (41-byte body)
D/OkHttp: <-- HTTP FAILED: java.net.SocketException: Socket closed
W/System.err: java.io.InterruptedIOException: timeout
W/System.err:     at okhttp3.internal.connection.Transmitter.timeoutExit(Transmitter.java:109)
W/System.err:     at okhttp3.internal.connection.Transmitter.maybeReleaseConnection(Transmitter.java:302)
W/System.err:     at okhttp3.internal.connection.Transmitter.noMoreExchanges(Transmitter.java:267)
W/System.err:     at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:237)
W/System.err:     at okhttp3.RealCall$AsyncCall.execute(RealCall.java:172)
W/System.err:     at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err:     at java.lang.Thread.run(Thread.java:818)
W/System.err: Caused by: java.net.SocketException: Socket closed
W/System.err:     at libcore.io.Posix.recvfromBytes(Native Method)
W/System.err:     at libcore.io.Posix.recvfrom(Posix.java:185)
W/System.err:     at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
W/System.err:     at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
W/System.err:     at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
W/System.err:     at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
W/System.err:     at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
W/System.err:     at okio.Okio$2.read(Okio.java:140)
W/System.err:     at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
W/System.err:     at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)
W/System.err:     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:230)
W/System.err:     at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.java:242)
W/System.err:     at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.java:213)
W/System.err:     at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.java:115)
W/System.err:     at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:94)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
W/System.err:     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
W/System.err:     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
W/System.err:     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
W/System.err:     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
W/System.err:     at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
W/System.err:     at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
W/System.err:   ... 5 more
하메드

마지막으로 많은 테스트 후 ISP 프록시 문제로 인해 오류가 발생하는 것을 발견했습니다. 바디와 PATCH 방식에 문제가 발생합니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Retrofit2 및 Gson이 logcat에 응답하지 않습니다.

분류에서Dev

Webmock이 쿼리로 스텁 요청에 응답하지 않음

분류에서Dev

Ajax 요청시 페이지가 일시적으로 응답하지 않음

분류에서Dev

Ajax 요청시 페이지가 일시적으로 응답하지 않음

분류에서Dev

AFNetworking 2-요청 실패시 응답 본문 없음

분류에서Dev

Ajax 요청이 응답하지 않음

분류에서Dev

Azure AAD-AADSTS50011 : 요청에 지정된 응답 URL이 응용 프로그램에 대해 구성된 응답 URL과 일치하지 않습니다.

분류에서Dev

Axios 패치 요청이 Laravel에서 작동하지 않음

분류에서Dev

nodejs가 새로운 Ubuntu 12.04.5에 설치된 후 npm이 응답하지 않음

분류에서Dev

Python 및 URLLIB2-웹 페이지를 요청하지만 응답을 기다리지 않음

분류에서Dev

cURL POST 요청이 Python 요청으로 작동하지 않음

분류에서Dev

Ubuntu 18.04에 apache2를 설치하고 시작하고 로컬 호스트의 요청에 응답하지만 외부에서는 응답하지 않습니다.

분류에서Dev

전환으로 인해 앱이 응답하지 않음

분류에서Dev

Caldav Radicale 서버가 이벤트 넣기 요청에 제대로 응답하지 않음

분류에서Dev

Caldav Radicale 서버가 이벤트 넣기 요청에 제대로 응답하지 않음

분류에서Dev

Retrofit2 POST 요청의 응답을 반환 널 (null)

분류에서Dev

grep -r "패턴"이 응답하지 않음

분류에서Dev

grep -r "패턴"이 응답하지 않음

분류에서Dev

동적보기 패널이 응답하지 않음

분류에서Dev

Rails 앱이 Postman 요청에 응답하지 않음

분류에서Dev

설치 중 파티션 테이블이 응답하지 않음

분류에서Dev

설치 중 파티션 테이블이 응답하지 않음

분류에서Dev

Xfce4 패널이 마우스 (터치 패드) 클릭에 응답하지 않음

분류에서Dev

터치 이벤트에 응답하지 않음

분류에서Dev

터치 스크린이 응답하지 않음

분류에서Dev

Angular 2 * ngfor는 순차적 http 요청 응답으로 업데이트되지 않습니다.

분류에서Dev

Retrofit2가 포함 된 Youtube API가 응답을 구문 분석 할 수 없음 (오류 : PlaylistItemListResponse에 PageInfo 유형이 LinkedHashMap 있음)

분류에서Dev

Retrofit2 + 코 틀린 방법 데이터 클래스로 GET 응답하는 동안 원시 JSON을 볼 수

분류에서Dev

Apache2 서버 페이지가 응답하지 않음

Related 관련 기사

  1. 1

    Retrofit2 및 Gson이 logcat에 응답하지 않습니다.

  2. 2

    Webmock이 쿼리로 스텁 요청에 응답하지 않음

  3. 3

    Ajax 요청시 페이지가 일시적으로 응답하지 않음

  4. 4

    Ajax 요청시 페이지가 일시적으로 응답하지 않음

  5. 5

    AFNetworking 2-요청 실패시 응답 본문 없음

  6. 6

    Ajax 요청이 응답하지 않음

  7. 7

    Azure AAD-AADSTS50011 : 요청에 지정된 응답 URL이 응용 프로그램에 대해 구성된 응답 URL과 일치하지 않습니다.

  8. 8

    Axios 패치 요청이 Laravel에서 작동하지 않음

  9. 9

    nodejs가 새로운 Ubuntu 12.04.5에 설치된 후 npm이 응답하지 않음

  10. 10

    Python 및 URLLIB2-웹 페이지를 요청하지만 응답을 기다리지 않음

  11. 11

    cURL POST 요청이 Python 요청으로 작동하지 않음

  12. 12

    Ubuntu 18.04에 apache2를 설치하고 시작하고 로컬 호스트의 요청에 응답하지만 외부에서는 응답하지 않습니다.

  13. 13

    전환으로 인해 앱이 응답하지 않음

  14. 14

    Caldav Radicale 서버가 이벤트 넣기 요청에 제대로 응답하지 않음

  15. 15

    Caldav Radicale 서버가 이벤트 넣기 요청에 제대로 응답하지 않음

  16. 16

    Retrofit2 POST 요청의 응답을 반환 널 (null)

  17. 17

    grep -r "패턴"이 응답하지 않음

  18. 18

    grep -r "패턴"이 응답하지 않음

  19. 19

    동적보기 패널이 응답하지 않음

  20. 20

    Rails 앱이 Postman 요청에 응답하지 않음

  21. 21

    설치 중 파티션 테이블이 응답하지 않음

  22. 22

    설치 중 파티션 테이블이 응답하지 않음

  23. 23

    Xfce4 패널이 마우스 (터치 패드) 클릭에 응답하지 않음

  24. 24

    터치 이벤트에 응답하지 않음

  25. 25

    터치 스크린이 응답하지 않음

  26. 26

    Angular 2 * ngfor는 순차적 http 요청 응답으로 업데이트되지 않습니다.

  27. 27

    Retrofit2가 포함 된 Youtube API가 응답을 구문 분석 할 수 없음 (오류 : PlaylistItemListResponse에 PageInfo 유형이 LinkedHashMap 있음)

  28. 28

    Retrofit2 + 코 틀린 방법 데이터 클래스로 GET 응답하는 동안 원시 JSON을 볼 수

  29. 29

    Apache2 서버 페이지가 응답하지 않음

뜨겁다태그

보관