Skip to content

Commit

Permalink
Merge pull request #63 from skalenetwork/hotfix/add-request-timeout
Browse files Browse the repository at this point in the history
Add post request timeout, add request body to the log
  • Loading branch information
DmytroNazarenko authored May 15, 2024
2 parents 5f8db94 + 622d42f commit 90cc5c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ events {
worker_processes auto;

http {
log_format upstreamlog '[$time_local] $request $status $host - $remote_addr to: $upstream_addr - urt: $upstream_response_time msec: $msec req_t: $request_time ($http_referer $http_user_agent)';
log_format upstreamlog '[$time_local] $request $status - $request_body - $host - $remote_addr to: $upstream_addr - urt: $upstream_response_time msec: $msec req_t: $request_time ($http_referer $http_user_agent)';
access_log /var/log/nginx/access.log upstreamlog;

limit_req_zone $binary_remote_addr zone=one:10m rate=200r/s;
Expand Down
2 changes: 1 addition & 1 deletion proxy/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def to_dict(self):

def url_ok(url) -> bool:
try:
r = requests.head(url)
r = requests.head(url, timeout=10)
return bool(r.status_code)
except requests.exceptions.ConnectionError:
return False
Expand Down
3 changes: 2 additions & 1 deletion proxy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def post_request(url, json, cookies=None):
return requests.post(
url,
json=json,
cookies=cookies
cookies=cookies,
timeout=30
)
except requests.exceptions.RequestException:
return None
Expand Down

0 comments on commit 90cc5c4

Please sign in to comment.