Skip to content

Commit 50ee890

Browse files
committed
Allow Ratchet/RFC6455 0.3
1 parent 920a8a0 commit 50ee890

8 files changed

+91
-12
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 2.1.4
2+
3+
- Allow Ratchet/RFC6455 0.3
4+
5+
# 2.1.3
6+
7+
- Forward compatibility with voryx/event-loop 3.0 while supporting 2.0
8+
19
# 2.1.2
210

311
- Update deps

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"react/http": "^0.7.3 | ^0.8",
4141
"react/http-client": "^0.5.3",
4242
"voryx/event-loop": "^3.0 || ^2.0.2",
43-
"ratchet/rfc6455": "^0.2.2",
43+
"ratchet/rfc6455": "^0.2.2 || ^0.3",
4444
"reactivex/rxphp": "^2.0.1"
4545
},
4646
"require-dev": {

test/TestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class TestCase extends FunctionalTestCase
99
{
10-
public function setup()
10+
public function setup(): void
1111
{
1212
parent::setup();
1313

@@ -29,4 +29,4 @@ public static function resetScheduler()
2929
$prop->setAccessible(false);
3030
}
3131
}
32-
}
32+
}

test/ab/clientRunner.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,26 @@
1212
$reportUrl = "ws://127.0.0.1:9001/updateReports?agent=" . AGENT . "&shutdownOnComplete=true";
1313
$client = new \Rx\Websocket\Client($reportUrl);
1414

15-
$client->subscribe();
15+
$client->subscribe(
16+
function (\Rx\Websocket\MessageSubject $messages) {
17+
echo "Report runner connected.\n";
18+
$messages->subscribe(new \Rx\Observer\CallbackObserver(
19+
function ($x) use ($messages) {
20+
echo "Message received by report runner connection: " . $x . "\n";;
21+
},
22+
[$messages, "onError"],
23+
[$messages, "onCompleted"]
24+
));
25+
},
26+
function (Throwable $error) {
27+
echo "Error on report runner connection:" . $error->getMessage() . "\n";
28+
echo "Seeing an error here might be normal. Network trace shows that AB fuzzingserver\n";
29+
echo "disconnects without sending an HTTP response.\n";
30+
},
31+
function () {
32+
echo "Report runner connection completed.\n";
33+
}
34+
);
1635
};
1736

1837
$runIndividualTest = function ($case, $timeout = 60000) {

test/ab/docker_bootstrap.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -x
3+
4+
echo "Running $0"
5+
6+
echo Adding "$1 host.ratchet.internal" to /etc/hosts file
7+
8+
echo $1 host.ratchet.internal >> /etc/hosts
9+
10+
echo /etc/hosts contains:
11+
cat /etc/hosts
12+
echo

test/ab/fuzzingclient.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"servers": [
66
{"agent": "RxWebsocketServer/0.0.0",
7-
"url": "ws://localhost:9001",
7+
"url": "ws://host.ratchet.internal:9001",
88
"options": {"version": 18}}
99
],
1010
"cases": ["*"],

test/ab/run_ab_tests.sh

+46-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,52 @@
1-
cd test/ab
1+
cd test/ab || exit
22

3-
wstest -m fuzzingserver -s fuzzingserver.json &
3+
docker run --rm \
4+
-d \
5+
-v ${PWD}:/config \
6+
-v ${PWD}/reports:/reports \
7+
-p 9001:9001 \
8+
--name fuzzingserver \
9+
crossbario/autobahn-testsuite wstest -m fuzzingserver -s /config/fuzzingserver.json
410
sleep 5
5-
php clientRunner.php
11+
12+
php -d memory_limit=256M clientRunner.php
13+
14+
docker ps -a
15+
16+
docker logs fuzzingserver
17+
18+
docker stop fuzzingserver
619

720
sleep 2
821

9-
php testServer.php 600 &
22+
23+
php -d memory_limit=256M testServer.php &
24+
SERVER_PID=$!
1025
sleep 3
11-
wstest -m fuzzingclient -s fuzzingclient.json
12-
sleep 12
26+
27+
if [ "$OSTYPE" = "linux-gnu" ]; then
28+
IPADDR=`hostname -I | cut -f 1 -d ' '`
29+
else
30+
IPADDR=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -1 | tr -d 'adr:'`
31+
fi
32+
33+
docker run --rm \
34+
-it \
35+
-v ${PWD}:/config \
36+
-v ${PWD}/reports:/reports \
37+
--name fuzzingclient \
38+
crossbario/autobahn-testsuite /bin/sh -c "sh /config/docker_bootstrap.sh $IPADDR; wstest -m fuzzingclient -s /config/fuzzingclient.json"
39+
sleep 1
40+
41+
kill $SERVER_PID
42+
43+
#wstest -m fuzzingserver -s fuzzingserver.json &
44+
#sleep 5
45+
#php clientRunner.php
46+
#
47+
#sleep 2
48+
49+
#php testServer.php 600 &
50+
#sleep 3
51+
#wstest -m fuzzingclient -s fuzzingclient.json
52+
#sleep 12

test/ab/testServer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$timerObservable = Observable::timer(1000 * $argv[1]);
1212
}
1313

14-
$server = new \Rx\Websocket\Server("tcp://127.0.0.1:9001", true);
14+
$server = new \Rx\Websocket\Server("tcp://0.0.0.0:9001", true);
1515

1616
$server
1717
->takeUntil($timerObservable)

0 commit comments

Comments
 (0)