Skip to content

Commit 091bee2

Browse files
committed
Avoid closing already closed streams
1 parent 43779e3 commit 091bee2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ReactMqttClient.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ public function connect($host, $port = 1883, Connection $connection = null, $tim
207207
$this->emitError($e);
208208
$deferred->reject($e);
209209

210-
$this->stream->close();
210+
if ($this->stream !== null) {
211+
$this->stream->close();
212+
}
213+
211214
$this->emit('close', [$connection, $this]);
212215
});
213216
})
@@ -244,7 +247,9 @@ public function disconnect()
244247
$this->emit('disconnect', [$connection, $this]);
245248
$deferred->resolve($connection);
246249

247-
$this->stream->close();
250+
if ($this->stream !== null) {
251+
$this->stream->close();
252+
}
248253
})
249254
->otherwise(function () use ($deferred) {
250255
$this->isDisconnecting = false;

0 commit comments

Comments
 (0)