Vitul Goyal
Vitul Goyal

Reputation: 621

Watching Bucket change from Compute Engine

I want to create a bucket watch notification from a VM Instance so that whenever i make some changes in the bucket, the VM knows about those changes.

I am able to create a notification using gsutil notification watchbucket. It gives me: Successfully created watch notification channel

The problem is i don't know how to read the notification from VM.

I tried the Client Application example given here: https://cloud.google.com/storage/docs/object-change-notification. I copied the code to a file called "notification" and while creating the notification channel i gave the path to this file but still i am not getting anything. Nothing is getting saved in the logs also.

It says the notification is sent as a POST request. I created a PHP file and read any POST variables and tried to save the request in a database. But nothing gets saved.

Can anyone please help me read these notifications.

Upvotes: 1

Views: 300

Answers (1)

Dave
Dave

Reputation: 3261

Two things to check. First, you need to be running an http server. I can't tell from your description if you're actually doing this. The client application example runs on App Engine, not Compute Engine. You'd need to do a few extra steps to get it running on Compute Engine (install webapp2 and use SimpleHTTPServer or a real http stack OR use Managed VMs).

Second thing to check is that you have a firewall open for the Compute Engine instance. Easiest way to do this is to look at the instance in the Developers Console and make sure the checkboxes under "Firewalls" are both checked.

Upvotes: 1

Related Questions