The community forums are in BETA and closed to the public.

Subscription to channel group does not appear to work

I am setting up pubnub for the first time. I can successfully subscribe and publish to channels, as well as add channels to groups. I can also successfully subscribe to channel groups. At least, an inspection of the pubnub object at runtime makes it look like I am subscribed to the groups I specified.

I have written a short application as a proof of concept. All it does is subscribe to extant channel groups asynchronously. It should do so, then hang out waiting for publications on the channel groups. What actually happens is that the subscriptions are made, then the program promptly exits. I receive no feedback from the callbacks (error, connection, or any other).

This is the code I am using to perform the subscriptions. It omits the callback method, and is excerpted from an object oriented design pattern:

def subscribeToChannelGroup(self, groupName, callback):
   self.pubnub.subscribe_group(groupName, callback=callback, error=self.error, connect=self.connect, reconnect=self.reconnect, disconnect=self.disconnect)

def error(message):
   print("ERROR : " + str(message))

def connect(message):

def reconnect(message):

def disconnect(message):

subscribeToChannelGroups('greatGroup', callback)

I can successfully subscribe to a channel and get the behavior I expect (the program waits for a message). I can NOT do this with a channel group. The program simply exits.

I would appear that you have not defined the variable callback when you call subscribeToChannelGroups.

Comments to this discussion are now closed!