You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that pub sub is not really async. After trying to figure out why I wasn't receiving commands on another client, I finally tried commenting out $client->subscribe($channel); and all of a sudden the publish commands were going through.
With a client subscribe the following code never logged the publish complete message:
$this->redis->publish($this->channel, json_encode($msg))->then(function($return) {
$this->debug('Publish received ' . $return);
});
The text was updated successfully, but these errors were encountered:
daneren2005
changed the title
Sub/Pub Is Not Async
Can't Pub/Sub On Same Client
Aug 19, 2016
You can easily reproduce this by connecting to your Redis instance via telnet:
$ telnet localhost 6379Trying127.0.0.1...
Connected to localhost.
Escape character is '^]'.
subscribe a
*3$9
subscribe
$1
a
:1
publish a b
-ERRonly (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context
As you've already figured out, the correct workaround is to use two independent connections.
Oh well that stinks. I was hoping because it async it meant you could listen for replies to the subscribe and publish on the same channel. That does make sense that it is a Redis thing which you can't work around.
It appears that pub sub is not really async. After trying to figure out why I wasn't receiving commands on another client, I finally tried commenting out
$client->subscribe($channel);
and all of a sudden the publish commands were going through.With a client subscribe the following code never logged the publish complete message:
The text was updated successfully, but these errors were encountered: