I am having issues in loading a web page where the response from the Spring server is getting cut-off from middle.
The HTML code starts out with the opening tags but doesn't completes, thus rendering empty page.
These are the response headers when the page is failing to load:
HTTP/1.1 200 OK
Server: Server
Date: Sun, 09 Jul 2023 16:25:48 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
Content-Language: en-GB
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Vary: accept-encoding,Content-Type,Accept-Encoding,User-Agent
Strict-Transport-Security: max-age=47474747; includeSubDomains; preload
Content-Length: 39528
These are the response headers when the page is able to load properly:
HTTP/1.1 200 OK
Server: Server
Date: Sun, 09 Jul 2023 16:25:27 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
Content-Language: en-GB
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Vary: accept-encoding,Content-Type,Accept-Encoding,User-Agent
Strict-Transport-Security: max-age=47474747; includeSubDomains; preload
Content-Length: 214865
As it could be seen, the Content-Length field is very small when the page is failing to load.
Complete HTML document from response is around 2500 lines but the erroneous response comes around 280 lines. And the size of incomplete content also changes with every page loads i.e. 285 lines, 282 lines, 301 lines etc. which shows it is not due to some special character(s).
I have also tried logging the HttpServletResponse using Spring Filters where the complete data is coming properly but somehow not reaching the browser.
I doubt this could be due to server configuration, since I am able to properly load different pages having larger sizes without any trouble from the same environment.
I have also tried changing the endpoint URL but it does not seem to have any relation here.
Caches have also been cleared multiple times. Tried it in different browsers.
No console log errors are getting displayed in browsers (since not enough content is coming to even complete the head tag in HTML document)
Response timeline for erroneous response:
* Received 8 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 7.5 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 5 B chunk
* Closing connection 5
* TLSv1.2 (IN), TLS header, Unknown (21):
* TLSv1.2 (IN), TLS alert, close notify (256):
* TLSv1.2 (OUT), TLS header, Unknown (21):
* TLSv1.2 (OUT), TLS alert, close notify (256):
Response timeline for proper response:
* Received 572 B chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 7.5 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 5.8 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 16 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 8.2 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 16 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 5.6 KB chunk
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Received 5 B chunk
* Closing connection 6
* TLSv1.2 (IN), TLS header, Unknown (21):
* TLSv1.2 (IN), TLS alert, close notify (256):
* TLSv1.2 (OUT), TLS header, Unknown (21):
* TLSv1.2 (OUT), TLS alert, close notify (256):
As per the response timelines, it could be seen that instead of receiving around ~60KB of data via different chunks, around ~16KB of chunk data is only getting transmitted.
Application code for both the cases are same.
Environment is different. But as stated earlier, the same environment is able to serve requests for other HTTP endpoints having large sizes from the same spring server instance.
Have re-deployed in this environment multiple times as well.
I am thinking maybe if the response from the Spring server for this specific request is not chunked such that it returns the entire content at one go, instead of multiple chunks, then I might be able to get the complete data.
Is there any way to do this in Spring?
Does anyone knows what could be the possible reason for this problem?
Would appreciate if someone could help me out here.
Thanks