Giter Club home page Giter Club logo

Comments (15)

cy6erGn0m avatar cy6erGn0m commented on May 2, 2024

в ветке с пайплайнами не ясно как сейчас работает стриминг вообще, требуется смёрджить три другие ветки (auth, streams и resources) в пайплайны, а потом пробовать. займёт несколько дней

на windows не тестировал вообще - это правда (нет такой машины под рукой).

Про облом на макоси хотелось бы поподробнее: что именно происходит?

from ktor.

cy6erGn0m avatar cy6erGn0m commented on May 2, 2024

проходят ли у вас тесты в master в маке и винде? в тестах есть тесты на serveFileSystem, в том числе и интеграционные для jetty.

какие файлы? большие или маленькие? какая java?

from ktor.

team55 avatar team55 commented on May 2, 2024

java 8, файлы все небольшие (html и javascript).
чуть позже прогоню тесты

from ktor.

team55 avatar team55 commented on May 2, 2024

Беру основную ветку.
java 1.8.0.72, mac os x mavericks, idea 2016.1.1
Тесты проходят.

Способ воспроизведения ошибки

Берем за основу ktor-samples-embedded
Добавляем в начало main

val targetClasses = File("ktor-samples/ktor-samples-embedded/target/classes")
println("LocalFiles in $targetClasses")

и после всех маршрутов

route("/files/") {
serveFileSystem(targetClasses)
}

чистим кеш браузера, стартуем приложение
запрашиваем http://localhost:8080/files/logback.xml
файл отдается около 30 сек (по информации в консоли браузера). Причем в той же консоли говорится что его длина 525 байтов (фактическая 429, разница 96 байт)

Соответственно если добавить каталог с html и сопутствующими файлами, запрашивается около 8 файлов с задержкой, остальные по таймауту отваливаются.

from ktor.

cy6erGn0m avatar cy6erGn0m commented on May 2, 2024

По крайней мере, на линуксе у меня не воспроизводится

time curl -D - 'http://localhost:8080/files/logback.xml'
HTTP/1.1 200 OK
Date: Tue, 12 Apr 2016 20:12:50 GMT
Last-Modified: Tue, 12 Apr 2016 23:03:59 GMT
Content-Type: application/xml; charset=UTF-8
Accept-Ranges: bytes
Content-Length: 429

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="trace">
        <appender-ref ref="STDOUT"/>
    </root>

    <logger name="org.eclipse.jetty" level="INFO"/>
    <logger name="io.netty" level="INFO"/>

</configuration>curl -D - 'http://localhost:8080/files/logback.xml'  
0,01s user 0,00s system 38% cpu 0,021 total

по всей видимости, это какая-то особенность макоси

from ktor.

cy6erGn0m avatar cy6erGn0m commented on May 2, 2024

или какие-то плохие заголовки ответа (дублированные или противоречивые заголовки, которые всё ещё могут иногда возникать).

Можете ли вы привести заголовки ответа из консоли браузера?

from ktor.

team55 avatar team55 commented on May 2, 2024

Request URL:http://localhost:8080/files/logback.xml
Request Method:GET
Status Code:200 OK
Remote Address:[::1]:8080

Response Headers
Accept-Ranges:bytes
Content-Encoding:gzip
Content-Length:429
Content-Type:application/xml; charset=UTF-8
Date:Wed, 13 Apr 2016 02:12:17 GMT
Last-Modified:Tue, 12 Apr 2016 23:11:55 GMT
Last-Modified:Tue, 12 Apr 2016 23:11:55 GMT

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
DNT:1
Host:localhost:8080
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36

from ktor.

team55 avatar team55 commented on May 2, 2024

прописал то же самое в тест - там все ок. Проблема именно с браузерами (в Safari то же самое)

URL("http://127.0.0.1:$port/files/${file.toRelativeString(targetClasses)}")
                    .openStream().buffered().use { it.readBytes() }.let { bytes ->
                assertEquals(file.length(), bytes.size.toLong())
            }

from ktor.

team55 avatar team55 commented on May 2, 2024

повторный запрос в хроме выполняется быстро - но тут понятно почему) Сброс кеша ставит все на свои места.

Request URL:http://localhost:8080/files/logback.xml
Request Method:GET
Status Code:304 Not Modified
Remote Address:[::1]:8080

Response Headers
Content-Type:application/xml; charset=UTF-8
Date:Wed, 13 Apr 2016 02:26:16 GMT
Last-Modified:Tue, 12 Apr 2016 23:11:55 GMT

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
DNT:1
Host:localhost:8080
If-Modified-Since:Tue, 12 Apr 2016 23:11:55 GMT
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36

from ktor.

team55 avatar team55 commented on May 2, 2024

c curl все ok

time curl -D - 'http://localhost:8080/files/logback.xml'
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2016 02:34:59 GMT
Last-Modified: Tue, 12 Apr 2016 23:11:55 GMT
Content-Type: application/xml; charset=UTF-8
Last-Modified: Tue, 12 Apr 2016 23:11:55 GMT
Accept-Ranges: bytes
Content-Length: 429

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="trace">
        <appender-ref ref="STDOUT"/>
    </root>

    <logger name="org.eclipse.jetty" level="INFO"/>
    <logger name="io.netty" level="INFO"/>

</configuration>
real    0m0.029s
user    0m0.005s
sys 0m0.007s

через час проверю на windows, сейчас нет под рукой

from ktor.

team55 avatar team55 commented on May 2, 2024

На windows точно такая же ситуация, размер в консоли 525 байтов


Request URL:http://localhost:8080/files/logback.xml
Request Method:GET
Status Code:200 OK
Remote Address:[::1]:8080

**Response Headers**
Accept-Ranges:bytes
Content-Encoding:gzip
Content-Length:429
Content-Type:application/xml; charset=UTF-8
Date:Wed, 13 Apr 2016 06:06:35 GMT
Last-Modified:Wed, 13 Apr 2016 11:59:29 GMT
Last-Modified:Wed, 13 Apr 2016 11:59:29 GMT

**Request Headers**
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
Cookie:JSESSIONID=1ev068u7y9oecbuoncq4e5qul
DNT:1
Host:localhost:8080
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36

from ktor.

cy6erGn0m avatar cy6erGn0m commented on May 2, 2024

всё понятно: невернеый content-length. Попробуйте взять ветку for.a отсюда https://github.com/cy6erGn0m/ktor/tree/for.a - проблема должна исчезнуть

from ktor.

team55 avatar team55 commented on May 2, 2024

Да, проблема исчезла.
Когда в планах pull request) ?

from ktor.

cy6erGn0m avatar cy6erGn0m commented on May 2, 2024

сейчас идёт большой рефакторинг (пайплайны, немного другая обработка асинхронных потоков, распил всякой логики, ресурсы) : там уже этих проблем нет, так что for.a это мой персональный бранч для накопления костылей. Скоро всё снова заработает :)

from ktor.

team55 avatar team55 commented on May 2, 2024

Понятно
Спасибо!

from ktor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.