mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
server: handle ECONNRESET in http connections
In real deployments, sometimes http connections break with ECONNRESET. This causes the kj::HttpServer listener promise to break, which means no more connections are accepted. Catch this exception and restart the listener. resolves #164
This commit is contained in:
parent
e1686d454b
commit
37bbf6ade4
@ -137,6 +137,14 @@ void Server::listenHttp(Http &http, kj::StringPtr httpBindAddress)
|
||||
if(httpBindAddress.startsWith("unix:"))
|
||||
chmod(httpBindAddress.slice(strlen("unix:")).cStr(), 0660);
|
||||
return http.startServer(ioContext.lowLevelProvider->getTimer(), kj::mv(listener));
|
||||
}).catch_([this,&http,httpBindAddress](kj::Exception&&e) mutable -> kj::Promise<void> {
|
||||
if(e.getType() == kj::Exception::Type::DISCONNECTED) {
|
||||
LLOG(ERROR, "HTTP disconnect, restarting server", e.getDescription());
|
||||
listenHttp(http, httpBindAddress);
|
||||
return kj::READY_NOW;
|
||||
}
|
||||
// otherwise propagate the exception
|
||||
return kj::mv(e);
|
||||
}));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user