The template could not be loaded. HTTP Status code: 0

Viewed 753

Please read the question in full before answering.

Problem Description: KnockoutJs is currently being used in our software for front-end templating. Sometimes a template request (xhr) doesn't get a and instead of the template appearing on the screen, the error:

"The template could not be loaded. HTTP Status code: 0."

is shown.

Problem Details:

  • This can happen to Any, All or None templates and the occurance seems to be random.
  • I have seen the bug in both Chrome and IE, but not in Firefox. On Chrome it seems to be more common.

  • The Status Code: 0 means that the request has not received a response, and this was confirmed in the network tab.

  • Once this message is shown (and the request failed) for a specific template, every other request for the same template will fail whilst still in the same http session.

  • This issue can be fixed in Chrome by opening DevTools -> Network Tab and checking the disable cache checkbox.

  • The bug can be seen in an incognito browser and refreshing a page with Ctrl-F5 doesn't seem to affect the bug, and doesn't fix it like the above point.

It seems to be a caching issue, I know. Here is where it gets interesting. We looked at the HTTP and SSL information via the events page found in chrome://net-internals for the templates where the errors occured and we seen the following:

SSL Info:

t=2156 [st= 0] +SOCKET_IN_USE  [dt=41]
                --> source_dependency = 4991 (HTTP_STREAM_JOB)
t=2156 [st= 0]    SOCKET_BYTES_SENT
                  --> byte_count = 957
t=2156 [st= 0]    SSL_SOCKET_BYTES_SENT
                  --> byte_count = 928
t=2197 [st=41]    SOCKET_READ_ERROR
                  --> net_error = -101 (ERR_CONNECTION_RESET)
                  --> os_error = 10054
t=2197 [st=41]    SSL_READ_ERROR
                  --> error_lib = 33
                  --> error_reason = 101
                  --> file = "c:\\b\\c\\b\\win64_pgo\\src\\net\\socket\\socket_bio_adapter.cc"
                  --> line = 107
                  --> net_error = -101 (ERR_CONNECTION_RESET)
                  --> ssl_error = 1
t=2197 [st=41]    SOCKET_CLOSED
t=2197 [st=41] -SOCKET_IN_USE
t=2197 [st=41] -SOCKET_IN_USE
t=2197 [st=41] -SOCKET_ALIVE

The socket_bio_adapter.cc file can be found here.

HTTP info:

...
t=2076 [st=  1]     -HTTP_TRANSACTION_SEND_REQUEST
t=2076 [st=  1]     +HTTP_TRANSACTION_READ_HEADERS  [dt=41]
t=2076 [st=  1]        HTTP_STREAM_PARSER_READ_HEADERS  [dt=40]
                       --> net_error = -101 (ERR_CONNECTION_RESET)
t=2116 [st= 41]        HTTP_TRANSACTION_RESTART_AFTER_ERROR
                       --> net_error = -101 (ERR_CONNECTION_RESET)
t=2117 [st= 42]     -HTTP_TRANSACTION_READ_HEADERS
t=2117 [st= 42]     +HTTP_STREAM_REQUEST  [dt=0]
t=2117 [st= 42]        HTTP_STREAM_JOB_CONTROLLER_BOUND
                       --> source_dependency = 4988 (HTTP_STREAM_JOB_CONTROLLER)
t=2117 [st= 42]        HTTP_STREAM_REQUEST_BOUND_TO_JOB
                       --> source_dependency = 4989 (HTTP_STREAM_JOB)
t=2117 [st= 42]     -HTTP_STREAM_REQUEST
...

It seems to be more than just a caching issue but I don't understand how this SSL SOCKET_READ_ERROR can be related to and fixed by disabling the cache in the DevTools.

Technical Details:

JQuery 2.2.4
KnockoutJs 3.2.0
TLS 1.2
Chrome 58.0.3029.110 (64-bit)

I've researched the problem and have found countless resources, but none of them seem to directly apply to this specific issue.

Questions:

  • What is going on here? How can the cache be directly related to SSL? Or does it just seem that way?

  • What woud clarify the sporadic nature of this issue?

Edit

I concluded that the requests that fail don't actually reach the application network. These requests are broken off client-side before they ever reach the backend landscape.

This was fixed by adding two extra HTTP headers (Cache-Control: no-cache, Pragma:no-cache) to all template requests before they are sent.

This fixes the problem but does not address the reason for it. Any insights into this problem is greatly appreciated.

0 Answers
Related