блокируются запросы при открытии трех одинаковых вкладок
В приложении постоянно крутится таймер, который обновляет токены. При открытии двух вкладок, все нормально. При открытии третьей, запросы отваливаются по таймауту, причем все и во всех вкладках. Смотрел в нгинксе, они туда даже попадают. т.е. что то с браузером или с axios. подозреваю какие то блокировки в браузере. Добавление хедеров отключающих кэширование не помогает. Сталкивался кто то с таким поведением ? Куда копать подскажите ?
async function retry<T>(todo: () => Promise<T>, retrys: number, delayMs: number): Promise<T> {
let r = 0;
let err;
do {
try {
return await todo();
} catch (error) {
if (error.response?.data?.error === "invalid_grant") {
throw error;
}
err = error;
r = r + 1;
//console.log(error);
console.log(`Retry: ${r}`);
if (r === retrys - 1) {
throw error;
}
await sleep(delayMs);
}
} while (r < retrys)
throw err;
}
export async function GetRefreshToken(username: string, password: string, pin: string) {
let resp: AxiosResponse;
const formData = new URLSearchParams();
formData.append("username", username);
formData.append("password", password);
formData.append("grant_type", "password");
formData.append("client_id", authClientId);
formData.append("client_secret", authClientSecret);
formData.append("scope", authScopes);
formData.append("two_fa", pin);
const client = axios.create();
const options = {
timeout: 5000,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
};
resp = await retry(async () => await client.post(tokenEndpoint, formData, options), 3, 5000);
return resp.data;
}
пример запроса:
curl -iv 'https://fancrypto.ru/connect/token' -H 'Accept: application/json, text/plain, */*' -H 'Cache-Control: no-cache, no-transform, no-store, max-age=3, must-revalidate' -H 'Referer: https://fancrypto.ru/invoices/invoice/14/1' -H 'Content-Type: application/x-www-form-urlencoded' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' -H 'Expires: -1' --data-raw 'refresh_token=FA84B084C5D037A949167A60CB0BF5D418A146DB2923040C371D5DFD722E173B&grant_type=refresh_token&client_id=browser&client_secret=secret&scope=trade+profile_security+openid+offline_access' --compressed
* Trying 127.0.0.1:443...
* TCP_NODELAY set
* Connected to fancrypto.ru (127.0.0.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=www.fancrypto.ru
* start date: Aug 9 12:19:30 2020 GMT
* expire date: Aug 15 10:05:48 2021 GMT
* subjectAltName: host "fancrypto.ru" matched cert's "fancrypto.ru"
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign RSA DV SSL CA 2018
* SSL certificate verify ok.
> POST /connect/token HTTP/1.1
> Host: fancrypto.ru
> Accept-Encoding: deflate, gzip, br
> Accept: application/json, text/plain, */*
> Cache-Control: no-cache, no-transform, no-store, max-age=3, must-revalidate
> Referer: https://fancrypto.ru/invoices/invoice/14/1
> Content-Type: application/x-www-form-urlencoded
> User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
> Expires: -1
> Content-Length: 193
>
* upload completely sent off: 193 out of 193 bytes
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< date: Thu, 31 Dec 2020 13:51:06 GMT
date: Thu, 31 Dec 2020 13:51:06 GMT
< content-type: application/json; charset=UTF-8
content-type: application/json; charset=UTF-8
< server: envoy
server: envoy
< cache-control: no-store, no-cache, max-age=0
cache-control: no-store, no-cache, max-age=0
< pragma: no-cache
pragma: no-cache
< x-envoy-upstream-service-time: 434
x-envoy-upstream-service-time: 434
< transfer-encoding: chunked
transfer-encoding: chunked
<
{"id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IkNCMTUyQ0U0RTk0MTgxQzVFNDREN0IxNzYzRkY5ODJBIiwidHlwIjoiSldUIn0.eyJuYmYiOjE2MDk0MjI2NjYsImV4cCI6MTYwOTQyMjk2NiwiaXNzIjoiaHR0cHM6Ly9mYW5jcnlwdG8ucnUiLCJhdWQiOiJicm93c2VyIiwiaWF0IjoxNjA5NDIyNjY2LCJhdF9oYXNoIjoid0JPM2FBblFmTWpCd3U2UVpFQ0twUSIsInN1YiI6IjE4ZjBkMDk1LWNmY2QtNDY1ZC04NGNkLTU4YmM3OTg0NDFjMiIsImF1dGhfdGltZSI6MTYwOTQwNjUwOCwiaWRwIjoibG9jYWwiLCJnaXZlbl9uYW1lIjoiWmVmaXIwMiIsImFtciI6WyJwd2QiXX0.zfniYLBEzUKUetSZ__-vdUr71yXHDj3tadzZK2Q9EIwYrQlCXOzvo2X1PEslIhKtDCSybZQSckjbuiSinxT_B2pimbBOprIc1yCx6JK4WNW_tuvHDC4luzm_q2sZInXa_iimdcVOTo-phbFnWV7zuiQ4d_SMQUmhm2CfKyMv_jhEawMfbq5GG2OjtE-BoXNMu1U90voHczs1nCAQtnCP8ofpk2pKX0TntWVFZHb6uP9lF4l8-xEpUjdxIuXMEXn6Swh2gKuE3ZUV3rqwNczGQQ5A24yXhYRGhUEEAR8fe4OJNgh5FsHtpF6bxvjNLF2aryb3qQq7T31iOJL-Sn80tA","access_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IkNCMTUyQ0U0RTk0MTgxQzVFNDREN0IxNzYzRkY5ODJBIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2MDk0MjI2NjYsImV4cCI6MTYwOTQyMjc0MSwiaXNzIjoiaHR0cHM6Ly9mYW5jcnlwdG8ucnUiLCJhdWQiOiJhcGkxIiwiY2xpZW50X2lkIjoiYnJvd3N* Connection #0 to host fancrypto.ru left intact
lciIsInN1YiI6IjE4ZjBkMDk1LWNmY2QtNDY1ZC04NGNkLTU4YmM3OTg0NDFjMiIsImF1dGhfdGltZSI6MTYwOTQwNjUwOCwiaWRwIjoibG9jYWwiLCJnaXZlbl9uYW1lIjoiWmVmaXIwMiIsImp0aSI6IjREQjU4QkYxOTZERUI3OUE4QkI5MzVDRjgxMjAzQTk3IiwiaWF0IjoxNjA5NDA2NTA4LCJzY29wZSI6WyJvcGVuaWQiLCJwcm9maWxlX3NlY3VyaXR5IiwidHJhZGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.s-HQ3Cb2ZG1GKbfqlrWZMED7TvWUvU7jX0q7yNAa6E2i4G39TXRE7k_qmYcQ4zg0LZXYsPgBjaWi0BBs_7AikB-LpAz5kPEYeuMT7vBX8tQw12aJ9ZG5_-IXdikRTrbsu-SaIeydyHPsVsRtti5tbhXzJzGOAwEXzTrUN-df0yyk7DV_pEt0mqzN4POcsE5-rwSaYnL4QPkxDfs96KdH5AddJ327zG3wccKOXDNZ1whC398MgF9EP63fBzLKsajD2ncSGJw4k85wf8n1Chiy129SzsOAc67xfymZUjU3DnN8RCy624Kc_KM9TqES8MuaQPJT4jAVedWUlarp6JlZew","expires_in":75,"token_type":"Bearer","refresh_token":"FA84B084C5D037A949167A60CB0BF5D418A146DB2923040C371D5DFD722E173B","scope":"openid profile_security trade offline_access"}