How to test Mirror API Subscriptions
Asked Answered
L

2

7

The restrictions of a https callbackUrl and the nature of the subscriptions as a whole makes it seem like this is something that can only be done with a publicly accessible url.

So far I have come across two potential solutions to make local development / debugging easier.

The first is the Subscription Proxy service offered by google. This workaround essentially lets you remove the SSL restriction and proxy subscription callbacks to a custom URL.

The second and most helpful way I have found to do development locally is to capture a subscription callback request (say from a server that is publicly accessible) into a log and then use curl to reproduce that request on your local/dev machine using something like:

curl -H "Content-type: application/json" -X POST \
  -d '{"json for":"the notification"}' http://localhost:8080/notify

Since the requests can sometimes be large, or you might want to test multiple callback types, I also found it useful to put the JSON of the subscript request into various files (ex: timeline-respond.json) and then run

curl -H "Content-Type: application/json" \
  --data @timeline-respond.json http://localhost:8080/notify

I'm curious as to what other people are doing to test their application subscriptions locally.

Lenard answered 3/6, 2013 at 23:8 Comment(2)
I have been trying similar approach (1) wcf service running in a local IIS server, tried with fiddler posting notification, it works fine, but it did not work from mirror service due to firewall settings, notification URL is not publicly accessible from mirror service, next option that i'm trying is that (2) to have an app engine web back-end and using XMPP to get notification to my glassware app(desktop app), i would like to see some easy workaround for debugging and development purpose.Roundup
Sorry for the newb question, but what exactly is curl?Facing
L
3

The command line curl technique that you mention is the best I've found to date.

I've experimented with other solutions, such as an App Engine subscription target paired with a local script which pulls that App Engine service for new notifications to relay to localhost, but so far I haven't found one that's worth the added complexity.

Alternatively, there are many localhost proxies available. My favorite is ngrok.com.

Longerich answered 3/6, 2013 at 23:17 Comment(2)
My servlet in localhost works on a specific url pattern: localhost:8080/plugins/servlet/glass.notify How can I setup ngrok to forward to this path on localhost?Facing
When you start ngrok you specify a local port to target. For you, this would be 8080. $ ngrok 8080 Once ngrok starts, it will tell you the domain to use, something like g6hadf.ngrok.com. Point your traffic here. Path information will be preserved, so a notification target might be g6hadf.ngrok.com/servlet/glass.notifyLongerich
M
0

You might want to give localtunnel a try.

Mazurek answered 7/12, 2013 at 14:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.