Small fixes, increase WS reconnection delay

This commit is contained in:
Reckless_Satoshi 2023-05-07 10:06:10 -07:00
parent 8434a256cf
commit 8ae18f8b2a
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
4 changed files with 7 additions and 7 deletions

View File

@ -105,7 +105,6 @@ const EncryptedSocketChat: React.FC<Props> = ({
connection.send({ connection.send({
message: robot.pubKey, message: robot.pubKey,
nick: userNick, nick: userNick,
authorization: `Token ${robot.tokenSHA256}`,
}); });
connection.onMessage((message) => setServerMessages((prev) => [...prev, message])); connection.onMessage((message) => setServerMessages((prev) => [...prev, message]));
@ -142,7 +141,6 @@ const EncryptedSocketChat: React.FC<Props> = ({
connection.send({ connection.send({
message: `-----SERVE HISTORY-----`, message: `-----SERVE HISTORY-----`,
nick: userNick, nick: userNick,
authorization: `Token ${robot.tokenSHA256}`,
}); });
} }
// If we receive an encrypted message // If we receive an encrypted message
@ -214,7 +212,6 @@ const EncryptedSocketChat: React.FC<Props> = ({
connection.send({ connection.send({
message: value, message: value,
nick: userNick, nick: userNick,
authorization: `Token ${robot.tokenSHA256}`,
}); });
setValue(''); setValue('');
} }
@ -230,7 +227,6 @@ const EncryptedSocketChat: React.FC<Props> = ({
connection.send({ connection.send({
message: encryptedMessage.toString().split('\n').join('\\'), message: encryptedMessage.toString().split('\n').join('\\'),
nick: userNick, nick: userNick,
authorization: `Token ${robot.tokenSHA256}`,
}); });
} }
}) })

View File

@ -276,7 +276,7 @@ export const useAppStore = () => {
}, [delay, currentOrder, page, badOrder]); }, [delay, currentOrder, page, badOrder]);
const orderReceived = function (data: any) { const orderReceived = function (data: any) {
if (data.bad_request != undefined) { if (data.bad_request) {
setBadOrder(data.bad_request); setBadOrder(data.bad_request);
setDelay(99999999); setDelay(99999999);
setOrder(undefined); setOrder(undefined);

View File

@ -3,7 +3,12 @@ import { WebsocketConnection } from '..';
class WebsocketConnectionWeb implements WebsocketConnection { class WebsocketConnectionWeb implements WebsocketConnection {
constructor(path: string) { constructor(path: string) {
this.rws = new ReconnectingWebSocket(path, [], { connectionTimeout: 15000 }); this.rws = new ReconnectingWebSocket(path, [], {
connectionTimeout: 15000,
reconnectionDelayGrowFactor: 1.5,
maxRetries: 15,
maxReconnectionDelay: 1000000,
});
} }
public rws: ReconnectingWebSocket; public rws: ReconnectingWebSocket;

View File

@ -160,7 +160,6 @@ class TokenAuthMiddleware(BaseMiddleware):
dict((x.split("=") for x in scope["query_string"].decode().split("&"))) dict((x.split("=") for x in scope["query_string"].decode().split("&")))
).get("token_sha256_hex", None) ).get("token_sha256_hex", None)
token_key = hex_to_base91(token_key) token_key = hex_to_base91(token_key)
print(token_key)
except ValueError: except ValueError:
token_key = None token_key = None
scope["user"] = ( scope["user"] = (