mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-02 12:36:06 -04:00
Time out HTTP federation requests
This commit is contained in:
parent
771892b314
commit
0e6b3e4e40
2 changed files with 29 additions and 2 deletions
|
@ -22,7 +22,7 @@ from twisted.web._newclient import ResponseDone
|
|||
|
||||
from synapse.http.agent_name import AGENT_NAME
|
||||
from synapse.http.endpoint import matrix_federation_endpoint
|
||||
from synapse.util.async import sleep
|
||||
from synapse.util.async import sleep, time_bound_deferred
|
||||
from synapse.util.logcontext import PreserveLoggingContext
|
||||
|
||||
from syutil.jsonutil import encode_canonical_json
|
||||
|
@ -78,6 +78,7 @@ class MatrixFederationHttpClient(object):
|
|||
self.signing_key = hs.config.signing_key[0]
|
||||
self.server_name = hs.hostname
|
||||
self.agent = MatrixFederationHttpAgent(reactor)
|
||||
self.clock = hs.get_clock()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _create_request(self, destination, method, path_bytes,
|
||||
|
@ -117,7 +118,7 @@ class MatrixFederationHttpClient(object):
|
|||
|
||||
try:
|
||||
with PreserveLoggingContext():
|
||||
response = yield self.agent.request(
|
||||
request_deferred = self.agent.request(
|
||||
destination,
|
||||
endpoint,
|
||||
method,
|
||||
|
@ -128,6 +129,12 @@ class MatrixFederationHttpClient(object):
|
|||
producer
|
||||
)
|
||||
|
||||
response = yield time_bound_deferred(
|
||||
request_deferred,
|
||||
clock=self.clock,
|
||||
time_out=60,
|
||||
)
|
||||
|
||||
logger.debug("Got response to %s", method)
|
||||
break
|
||||
except Exception as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue