Skip to content

Commit 0cac961

Browse files
committed
Use ECONNABORTED error code for explicit connection cancelation
1 parent 94da388 commit 0cac961

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ See also the [first example](examples).
196196
The `tcp://` scheme can also be omitted.
197197
Passing any other scheme will reject the promise.
198198

199-
Pending connection attempts can be cancelled by cancelling its pending promise like so:
199+
Pending connection attempts can be canceled by canceling its pending promise like so:
200200

201201
```php
202202
$promise = $connector->connect($uri);
@@ -237,7 +237,7 @@ If you use the low-level `SecureConnector`, then the `tls://` scheme can also
237237
be omitted.
238238
Passing any other scheme will reject the promise.
239239

240-
Pending connection attempts can be cancelled by cancelling its pending promise
240+
Pending connection attempts can be canceled by canceling its pending promise
241241
as usual.
242242

243243
> Also note how secure TLS connections are in fact entirely handled outside of
@@ -396,7 +396,7 @@ $connector = new React\Socket\Connector($loop, array(
396396

397397
See also the [fourth example](examples).
398398

399-
Pending connection attempts can be cancelled by cancelling its pending promise
399+
Pending connection attempts can be canceled by canceling its pending promise
400400
as usual.
401401

402402
> Also note how local DNS resolution is in fact entirely handled outside of this
@@ -494,7 +494,7 @@ $connector->connect('tls://www.google.com:443')->then(function ($stream) {
494494

495495
See also the [third example](examples).
496496

497-
Pending connection attempts can be cancelled by cancelling its pending promise
497+
Pending connection attempts can be canceled by canceling its pending promise
498498
as usual.
499499

500500
Proxy chaining can happen on the server side and/or the client side:
@@ -541,7 +541,7 @@ $connector->connect('tcp://google.com:80')->then(function ($stream) {
541541

542542
See also any of the [examples](examples).
543543

544-
Pending connection attempts can be cancelled by cancelling its pending promise
544+
Pending connection attempts can be canceled by canceling its pending promise
545545
as usual.
546546

547547
> Also note how connection timeout is in fact entirely handled outside of this

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function (Exception $e) {
179179
public function handleConnectedSocks(ConnectionInterface $stream, $host, $port)
180180
{
181181
$deferred = new Deferred(function ($_, $reject) {
182-
$reject(new RuntimeException('Connection attempt cancelled while establishing socks session'));
182+
$reject(new RuntimeException('Connection canceled while establishing SOCKS session (ECONNABORTED)', defined('SOCKET_ECONNABORTED') ? SOCKET_ECONNABORTED : 103));
183183
});
184184

185185
$reader = new StreamReader();

tests/ClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ public function testCancelConnectionDuringSessionWillCloseStream()
157157
$promise = $this->client->connect('google.com:80');
158158
$promise->cancel();
159159

160-
$this->expectPromiseReject($promise);
160+
$promise->then(null, $this->expectCallableOnceWithExceptionCode(SOCKET_ECONNABORTED));
161161
}
162162
}

tests/ServerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function testConnectWillCancelConnectionIfStreamCloses()
138138
$promise->then(null, $this->expectCallableOnce());
139139
}
140140

141-
public function testConnectWillAbortIfPromiseIsCancelled()
141+
public function testConnectWillAbortIfPromiseIsCanceled()
142142
{
143143
$stream = $this->getMockBuilder('React\Socket\ConnectionInterface')->getMock();
144144

0 commit comments

Comments
 (0)