This commit is contained in:
Ben Wilson
2023-07-22 13:55:25 -04:00
parent 7b5a0756a2
commit 14729a193b
2 changed files with 5 additions and 10 deletions
+4 -9
View File
@@ -90,7 +90,7 @@ export class StratumV1Client extends EasyUnsubscribe {
parsedMessage = JSON.parse(message); parsedMessage = JSON.parse(message);
} catch (e) { } catch (e) {
console.log("Invalid JSON"); console.log("Invalid JSON");
await this.promiseSocket.end(); this.promiseSocket.socket.emit('end', true);
return; return;
} }
@@ -254,7 +254,6 @@ export class StratumV1Client extends EasyUnsubscribe {
if (this.clientSubscription != null if (this.clientSubscription != null
// && this.clientConfiguration != null
&& this.clientAuthorization != null && this.clientAuthorization != null
&& this.stratumInitialized == false) { && this.stratumInitialized == false) {
@@ -296,9 +295,9 @@ export class StratumV1Client extends EasyUnsubscribe {
const now = Date.now(); const now = Date.now();
const diffSeconds = (now - time.getTime()) / 1000; const diffSeconds = (now - time.getTime()) / 1000;
// five minutes // five minutes
if (diffSeconds > 60 * 5) { if (diffSeconds > 5 * 60) {
console.log('Watchdog ending session'); console.log('Watchdog ending session');
await this.promiseSocket.end(); this.promiseSocket.socket.emit('end', true);
} }
} }
@@ -332,12 +331,8 @@ export class StratumV1Client extends EasyUnsubscribe {
this.stratumV1JobsService.addJob(job); this.stratumV1JobsService.addJob(job);
await this.promiseSocket.write(job.response(jobTemplate));
try {
await this.promiseSocket.write(job.response(jobTemplate));
} catch (e) {
await this.promiseSocket.end();
}
console.log(`Sent new job to ${this.clientAuthorization.worker}.${this.extraNonceAndSessionId}. (clearJobs: ${jobTemplate.blockData.clearJobs}, fee?: ${!noFee})`) console.log(`Sent new job to ${this.clientAuthorization.worker}.${this.extraNonceAndSessionId}. (clearJobs: ${jobTemplate.blockData.clearJobs}, fee?: ${!noFee})`)
+1 -1
View File
@@ -76,7 +76,7 @@ export class StratumV1Service implements OnModuleInit {
await this.clientService.delete(client.extraNonceAndSessionId); await this.clientService.delete(client.extraNonceAndSessionId);
const clientCount = await this.clientService.connectedClientCount(); const clientCount = await this.clientService.connectedClientCount();
console.error(`Socket error:`, error); console.log(`Socket error:`, error);
console.log(`Client disconnected: ${promiseSocket.socket.remoteAddress}, ${client.extraNonceAndSessionId}, ${clientCount} total clients`); console.log(`Client disconnected: ${promiseSocket.socket.remoteAddress}, ${client.extraNonceAndSessionId}, ${clientCount} total clients`);
}); });