Testing Google Cloud PubSub Local Endpoints

Trying to figure out the best way to test PubSub endpoints locally. We tried with ngrok.io, but you have to own a domain to get a whitelist (the tool for this also does not work ... the result is an endless loop of forwarding). We also tried to simulate PubSub locally. I can publish and pull, but I cannot get push subscriptions to work. We use the local Flask web server:

@app.route('/_ah/push-handlers/events', methods=['POST']) def handle_message(): print request.json return jsonify({'ok': 1}), 200 

Below the result is not obtained:

 client = pubsub.Client() topic = client('events') topic.create() subscription = topic.subscription('test_push', push_endpoint='http://localhost:5000/_ah/push-handlers/events') subscription.create() topic.publish('{"test": 123}') 

He yells at us when we try to subscribe to an HTTP endpoint (whereas there will be live PubSub if you are not using HTTPS). Perhaps this is by design? Pull works just fine ... Any ideas on how best to develop PubSub guide endpoints locally?

+6
source share
1 answer

This may be a known bug (fix the upcoming) in the emulator where push endpoints created with the subscription are not created. The error only affects the initial push configuration; Changing the push configuration for an existing subscription should work. Can you try this?

0
source

All Articles