I am trying to make a basic connection to PubNub and get some basic output with python. When I run the files in bash on windows I am getting a 504 error. I checked Pubnub and it says I am getting some usage which is strange. I am using pubnub 4.1.6
Any help with this would be much appreciated
Thank you so much for your help in advance
Please see the image to see the code I run and the error I am getting.
import time
from pubnub.pubnub import PubNub
from pubnub.pnconfiguration import PNConfiguration
from pubnub.callbacks import SubscribeCallback
pnconfig = PNConfiguration()
#pnconfig.ssl = True
pnconfig.subscribe_key = subscribe_key = 'XXX'
pnconfig.publish_key = publish_key ='XXX'
pubnub = PubNub(pnconfig)
'''Test Channel global variable'''
TEST_CHANNEL = 'TEST_CHANNEL'
pubnub.subscribe().channels([TEST_CHANNEL]).execute()
'''
Listen class extends SubscribeCallback and herits its behaviour
Must be put into a class as it's equipped to handle the different events that occur in this channel
'''
class Listener(SubscribeCallback):
def message(self, pubnub, message_object):
print(f'\n-- Incoming message object: {message_object}')
'''Instansiate an instance of message class within a call to add listener'''
pubnub.add_listener(Listener())
def main():
'''Sleep to ensure subsribe runs runs'''
time.sleep(1)
pubnub.publish().channel(TEST_CHANNEL).message({'foo': 'bar'}).sync()
if __name__=='main':
main()