Last post Oct 08, 2019 05:11 AM by kedarkdr
Oct 04, 2019 01:28 PM|kedarkdr|LINK
HttpclientFactory of .net core doesn't seem to keep the connection or handler in established mode of the request is made to express js server, however if the request is made to a .net server then the connection remains in established state for default 2
I have a very simple express web app, which has below route, and server is listening on port 3000
app.get('/text', (req, res) => res.json('Sample text.'));
and from .net application the call is made as below
_var httpClient = httpClientFactory.CreateClient();
var request = new HttpRequestMessage(
using (var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
var stream = await response.Content.ReadAsStreamAsync();
when connection status is checked using netstat -a, the connection goes into close_wait mode immediately after the call.
any inputs are appreciated
Oct 04, 2019 02:31 PM|PatriceSc|LINK
It seems you are telling the same code does work with a ".NET server" ? IMHO it is an issue on the "express js server" side. Not a socket expert but it might be related to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive which
is perhaps not supported by this server?
Edit; this is an http 1.0 server maybe ? According to https://en.wikipedia.org/wiki/HTTP_persistent_connection it needs to be requested with http 1.0
and the server sends back a confirmation apparently. In http 1.1 it is the default.
IMO try a forum for the web server with which you have this behavior.
Oct 04, 2019 03:21 PM|bruce (sqlwork.com)|LINK
The express default keep-alive is 5 seconds. Change it’s configuration if you want it to match.
Oct 08, 2019 05:11 AM|kedarkdr|LINK
Thanks, modifying the keep-alive time keep the connection open for longer time