Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-4419 Ignore request timeout for WebSocket requests #3062

Merged
merged 1 commit into from Jun 21, 2022
Merged

Conversation

e5l
Copy link
Member

@e5l e5l commented Jun 20, 2022

Fix KTOR-4419

@e5l e5l requested a review from rsinukov June 20, 2022 09:54
@e5l e5l self-assigned this Jun 20, 2022
@e5l e5l changed the title KTOR-4457 Ignore request timeout for WebSocket requests KTOR-4419 Ignore request timeout for WebSocket requests Jun 20, 2022
* The request timeout is handled by the plugin and disabled for the WebSockets.
*/
val isWebSocket = request.url.protocol.isWebsocket()
if (request.getCapabilityOrNull(HttpTimeout) != null || isWebSocket || request.isUpgradeRequest()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why we do request.getCapabilityOrNull(HttpTimeout) != null here?

Copy link
Member Author

@e5l e5l Jun 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CIO engine had timeouts before we had the HttpTimeout plugin. This place handles only the case when the plugin is not installed.

fun testRequestTimeoutIgnoredWithWebSocket(): Unit = runBlocking {
val client = HttpClient(CIO) {
engine {
requestTimeout = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make it shorted, to avoid running test for 20 seconds

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ms

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, ok. sorry =)

install(WebSockets)

install(HttpTimeout) {
requestTimeoutMillis = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here the same :)

@e5l e5l requested a review from rsinukov June 21, 2022 08:13
@e5l e5l merged commit 33bb14f into main Jun 21, 2022
@e5l e5l deleted the e5l/ws-timeout branch June 21, 2022 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants