Reputation: 53
On occasion (not consistently), I'm receiving a "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server" exception thrown by an instance of the JsonServiceClient. I want to set the Http Connection Header to Close.
When I attempt client.Headers["Connection"] = "Close"; "I get a The 'Connection' header must be modified using the appropriate property or method.\r\nParameter name: name" exception.
Upvotes: 1
Views: 1399
Reputation: 44
you can Just use this to close the connection {Connection: close};
Upvotes: 0
Reputation: 143379
You can set the HTTP Request Connection header using a Request Filter, e.g:
var client = new JsonServiceClient {
RequestFilter = req => req.Connection = "Close"
};
Upvotes: 1