diff --git a/src/models/StratumV1Client.ts b/src/models/StratumV1Client.ts index 368ffbe..275eb1d 100644 --- a/src/models/StratumV1Client.ts +++ b/src/models/StratumV1Client.ts @@ -574,12 +574,15 @@ export class StratumV1Client { return true; } else { console.error('Error: Cannot write to closed or ended socket.'); + return false; } } catch (error) { - await this.socket.end(); + if (!this.socket.destroyed && !this.socket.writableEnded) { + await this.socket.end(); + } console.error('Error occurred while writing to socket:', error); + return false; } - return false; } } \ No newline at end of file