vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
619 stars 167 forks source link

Vaadin Push Client stuck if Push annotation is used in OpenLiberty with Turkish Localization #14162

Open abdullahtellioglu opened 2 years ago

abdullahtellioglu commented 2 years ago

Description of the bug

When I set push annotation @Push(value = PushMode.AUTOMATIC, transport = Transport.LONG_POLLING) as Long Polling or WEBSOCKET, in the browser FlowClient sends request infinitely.

Open Liberty Push

Even though it is set to LONG_POLLING, Flow client is using Atmosphere library to send request.

Also in the Javascript console FlowClient logs re-opening push connection infinitely.

Reopening push connection infinitely

Expected behavior

It should send request with an interval. Should not stuck at infinite loop. Maybe do not use the atmosphere library if transport method is set to LONG_POLLING.

Minimal reproducible example

See https://github.com/abdullahtellioglu/openliberty-push-example and run mvn clean install liberty:dev to create a reproducible example. Open the url http://localhost:9080/push/ and open the network tab in development tool.

Versions

mcollovati commented 2 years ago

Just tried your example and I can't reproduce the problem. Long polling for push is handled by Atmosphere, so it is ok. On the network tab I see a PUSH connection being established (v-r=push&X-Atmosphere-Transport=long-polling) and stay pending until there's some interaction.

MarcinVaadin commented 2 years ago

Tested on MacOS 12.4 on Safari Version 15.5 (17613.2.7.1.8) and Chrome Version 103.0.5060.114 (Official Build) (arm64) and on both it looks the same - no push reopening:

image
abdullahtellioglu commented 2 years ago

I tested and tried to find out what might be the reason and in AtmosphereFramework.java it checks the header of X-Atmosphere-tracking-id which is not sent from Client in any time. That is why it tries to reconnect.

Atmosphere Framework

An Example Client Request:

GET /Portal/app/?v-r=push&v-uiId=1&v-pushId=190bda15-e36a-4c48-ac9b-2f8f0c4973d2&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=3.1.2-javascript&X-Atmosphere-Transport=long-polling&X-Atmosphere-TrackMessageSize=true&Content-Type=application%2Fjson%3B%20charset%3DUTF-8&X-atmo-protocol=true&_=1657622041682 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Content-Type: application/json; charset=UTF-8
Cookie: JSESSIONID=0000aHx57ou1ixMOl64THUUTWA2:f3fbf528-471a-41ac-a18c-9f6e160a0f8c
Host: localhost:9080
Referer: http://localhost:9080/Portal/app/layout
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"

Response of that request

HTTP/1.1 200 OK
X-Powered-By: Servlet/4.0
X-Atmosphere-first-request: true
X-Atmosphere-tracking-id: 0e031acc-6dbf-489c-81cf-203f36475342
Expires: -1
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Content-Language: tr-TR
Transfer-Encoding: chunked
Date: Tue, 12 Jul 2022 10:34:01 GMT

X-Atmosphere-id on the next request is not send again and it creates an infinite loop like this.

abdullahtellioglu commented 2 years ago

The problem is happening if locale is set Turkish in JVM options. If JVM property is set -Duser.language=tr and create a js bundle, this bug is happening.

Artur- commented 2 years ago

Turkish locale issues are most often caused by using toLowerCase without specifying an English locale to convert an I to i and you end up with a Turkish i instead. When matching for fields/methods/headers/cookies it then fails at some point because the expected key is not found