repejota / phpnats

A PHP client for the NATSio cloud messaging system.

Home Page:http://nats.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nats\Exception: Subscription not found

apocello2008 opened this issue · comments

Hello. I have some troubles with messages. After ~19 000 messages per second my worker is down with error:

Nats\Exception: Subscription not found: 0c6e8d428d94756d16b1a290a5f385bf in /home/vfeuerbach/v2/tmp/coordinator/vendor/repejota/nats/src/Nats/Exception.php:48
Stack trace:
#0 /home/vfeuerbach/v2/tmp/coordinator/vendor/repejota/nats/src/Nats/Connection.php(420): Nats\Exception::forSubscriptionNotFound('0c6e8d428d94756...')
#1 /home/vfeuerbach/v2/tmp/coordinator/vendor/repejota/nats/src/Nats/Connection.php(603): Nats\Connection->handleMSG('MSG _INBOX.596f...')
#2 /home/vfeuerbach/v2/tmp/coordinator/vendor/repejota/nats/src/Nats/Connection.php(497): Nats\Connection->wait(1)
#3 /home/vfeuerbach/v2/tmp/coordinator/run.php(68): Nats\Connection->request('queue', '{"corid":"djhfj...', Object(Closure))

And another strange thing.. If i make requests like in example i have 40-50ms lat. But if i make unsubscribe lat. is 1-5ms. Example here:

Here: 50ms. lat.

 $conn->request('queue', $msg, function ($response) {
// Processing...
});

Here: 5ms. lat.

 $conn->request('queue', $msg, function ($response) {
// Processing...
});
$conn->unsubscribe('queue');

Update: I make little load testing via ab (ApacheBench). I set params -n 2 and -c 2 (two requests in one time). And i have error:
Nats\Exception: Subscription not found: 546862e7d4954cb50a1a373fd3a2e5a2

That's interesting!
Taking a look 💪

Thans for your answer and time, i have a little data trace for you:

Here is responce data:

string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3867}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3867}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3868}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3867}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3868}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3867}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3869}}"
string(101) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.387}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3871}}"
string(102) "{"type":"pong","status":20MSG _INBOX.5970418d5e883 84496f6969eb9a2e670752ce0f5bcfc1 102
{"type":"pong"

As you can see, PHP parse response incorrected.

Here second dump:

string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3877}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3877}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3887}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3887}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3888}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3888}}"
string(102) "{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3889}}"
string(102) "{"type":"pong","status":2070418d5ef56 76dad8a9ec8321ca2526d27705d44263 102
{"type":"pong","status":20"

And response damaged again :(

Update:

{"type":"pong","status":200,"message":{"instance":"office_local","process_timestamp":1500529037.3867}}

This string is my test response data. Not part of NATS protocol :)