Я использую Okhttp3 для отправки XML-файла http-Request. Когда я пытаюсь отправить длинный файл (несколько тысяч строк), я получаю исключение StreamResetException. В остальном всегда работает нормально, ошибка возникает только с очень длинным XML-файлом. Мой код выглядит следующим образом:
Request request = new Request.Builder()
.url(url)
.addHeader(SENDER, Sender)
.addHeader(NACHRICHTUUID, Uuid)
.addHeader(SCHEMEAGENCYID, SchemeId)
.addHeader(AUTHORIZATION, token)
.post(RequestBody.create(xml, MediaType.get(APPLICATION_XML)))
.build();
Response response = getHttpClient().newCall(request).execute()
private OkHttpClient getHttpClient()
{
if (httpClient == null)
{
httpClient = new OkHttpClient.Builder()
.callTimeout(30, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build();
}
return httpClient;
}
Я получаю следующее сообщение об ошибке:
okhttp3.internal.http2.StreamResetException: stream was reset: NO_ERROR
at okhttp3.internal.http2.Http2Stream.checkOutNotClosed$okhttp(Http2Stream.kt:646) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http2.Http2Stream$FramingSink.emitFrame(Http2Stream.kt:557) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http2.Http2Stream$FramingSink.write(Http2Stream.kt:532) ~[okhttp-4.9.3.jar:na]
at okio.ForwardingSink.write(ForwardingSink.kt:29) ~[okio-2.8.0.jar:na]
at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:218) ~[okhttp-4.9.3.jar:na]
at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:255) ~[okio-2.8.0.jar:na]
at okio.RealBufferedSink.write(RealBufferedSink.kt:185) ~[okio-2.8.0.jar:na]
at okhttp3.RequestBody$Companion$toRequestBody$2.writeTo(RequestBody.kt:152) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:59) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.9.3.jar:na]
Подробнее здесь: https://stackoverflow.com/questions/782 ... ong-reques
Как решить проблему StreamResetException: поток был сброшен: NO_ERROR с длинным телом запроса ⇐ JAVA
Программисты JAVA общаются здесь
1722369641
Anonymous
Я использую Okhttp3 для отправки XML-файла http-Request. Когда я пытаюсь отправить длинный файл (несколько тысяч строк), я получаю исключение StreamResetException. В остальном всегда работает нормально, ошибка возникает только с очень длинным XML-файлом. Мой код выглядит следующим образом:
Request request = new Request.Builder()
.url(url)
.addHeader(SENDER, Sender)
.addHeader(NACHRICHTUUID, Uuid)
.addHeader(SCHEMEAGENCYID, SchemeId)
.addHeader(AUTHORIZATION, token)
.post(RequestBody.create(xml, MediaType.get(APPLICATION_XML)))
.build();
Response response = getHttpClient().newCall(request).execute()
private OkHttpClient getHttpClient()
{
if (httpClient == null)
{
httpClient = new OkHttpClient.Builder()
.callTimeout(30, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build();
}
return httpClient;
}
Я получаю следующее сообщение об ошибке:
okhttp3.internal.http2.StreamResetException: stream was reset: NO_ERROR
at okhttp3.internal.http2.Http2Stream.checkOutNotClosed$okhttp(Http2Stream.kt:646) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http2.Http2Stream$FramingSink.emitFrame(Http2Stream.kt:557) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http2.Http2Stream$FramingSink.write(Http2Stream.kt:532) ~[okhttp-4.9.3.jar:na]
at okio.ForwardingSink.write(ForwardingSink.kt:29) ~[okio-2.8.0.jar:na]
at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:218) ~[okhttp-4.9.3.jar:na]
at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:255) ~[okio-2.8.0.jar:na]
at okio.RealBufferedSink.write(RealBufferedSink.kt:185) ~[okio-2.8.0.jar:na]
at okhttp3.RequestBody$Companion$toRequestBody$2.writeTo(RequestBody.kt:152) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:59) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.9.3.jar:na]
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.9.3.jar:na]
Подробнее здесь: [url]https://stackoverflow.com/questions/78293271/how-to-solve-streamresetexception-stream-was-reset-no-error-with-a-long-reques[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия