Uninstalled Webhook not firing

Solved
TezWingfield83
Tourist
15 0 1

Hi All,

This is driving me bonkers! I've literally rewrote my func four times to try and understand why I'm not receiving an uninstalled event.

 

Ok, So, I'm testing locally via ngrok. I've spent the best part of the day wiring up the auth, all is working fine except, uninstalling.

 

topic: app/uninstalled

address: https://******.ngrok.io/shopify/uninstall

format: json.

 

I log the response from the api (looks good), I can see the hook via postman (GET request)

 

I've stripped out all the code on the uninstalled endpoint on my mvc app and I'm left with:

 

[HttpPost]
public IActionResult Index()
{
return new OkResult();
}

 

It's just not being hit.

Please can someone point me in the right direction?

 

Stay Safe,

 

 

Accepted Solution (1)

Accepted Solutions
_JB
Shopify Staff
Shopify Staff
836 99 211

This is an accepted solution.

@TezWingfield83,

The logs confirm a webhook is indeed firing, but your endpoint is responding with a 503 error. They're being sent to https://[removed].ngrok.io/Shopify/Uninstall . Hopefully that helps with troubleshooting.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 25 (25)
TezWingfield83
Tourist
15 0 1

Bump...

 

Anyone else seeing these problems? I really could do with a tech rep from shopify to help identify the issues.

 

I've tested again this morning, leaving the dev/ngrok server running incase of delay... but 30mins in, and still no data received. 

 

Are there any reported issues using ngrok in a test env? How can I tell if the shopify system even attempted to make this call? Happy to share further details in a private message.

 

Regards,

TezWingfield83
Tourist
15 0 1

Bump Bump...

 

Anyone? I take it the Shopify team don't work on the weekends. No rotating team I guess.

 

HunkyBill
Shopify Expert
4764 54 551

If your App is not getting hit with a webhook, 99% of the time the problem is, you have not configured your App correctly. So you say Postman registers the hit. Great. Now when you examine the webhook you setup in the App you're about to uninstall, you are 100% certain you did that step correctly, and you see your topic and endpoint perfect right?

Only in that case would I even pretend there is a problem with Shopify... 99% of the time, the problem was me. And what I did. And the DUH moments are there.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
TezWingfield83
Tourist
15 0 1

Evening Bill,

Thank you very much for the reply. It's truly appreciated.

I completely agree that mistakes and bugs can happen. My day job is a software engineer, so I'm well versed in the art of developing systems.

 

So, My auth is working. During the callback process, I call the POST webhook endpoint, which certainly creates the hook. The resp from the call:

{"webhook":{"id":****,"address":"https:\/\/****ngrok.io\/shopify\/uninstall\/index\/","topic":"app\/uninstalled","created_at":"2021-04-18T20:33:08+01:00","updated_at":"2021-04-18T20:33:08+01:00","format":"json","fields":[],"metafield_namespaces":[],"api_version":"2021-04","private_metafield_namespaces":[]}}

I also store the config to a table:

topic: app/uninstalled

address: https://****.ngrok.io/shopify/uninstall/index/

format: json

And finally when I get all webhooks using postman, I can certainly see the one I created:

 

        {
            "id"****,
            "address""https://***.ngrok.io/shopify/uninstall/index/",
            "topic""app/uninstalled",
            "created_at""2021-04-18T20:33:08+01:00",
            "updated_at""2021-04-18T20:33:08+01:00",
            "format""json",
            "fields": [],
            "metafield_namespaces": [],
            "api_version""2021-04",
            "private_metafield_namespaces": []
        }

 

I've now included a logging method and left my dev server running:

 

[HttpPost]
public async Task<IActionResult> Index()
{

_loggerHelper.Log(LogType.Database, "UninstallController.cs", "Uninstall", "Uninstall Endpoint Hit!");
return new OkResult();
}

 

You say not configured app? Are you referring to the app in shopify (Create App section). Do I need to whitelist some where?

 

And finally if I take my url "uninstall" change the verb to post in postman, I can hit my own app... I really wish there was a "DUH" moment but I'm not seeing it.

 

Regards,

 

 

 

 

 

HunkyBill
Shopify Expert
4764 54 551

What I meant is, your App is probably not configured properly at the endpoint. Shopify is almost certainly sending you the webhook if you are uninstalling the App. If your endpoint remains unhit, it is likely you are either not listening to the right endpoint with the right verb... or something else is misconfigured. As I said before, there will likely be a duh moment for you.

There is nothing to whitelist. If you set a webhook in an App, and you checked it exists, and you trigger it, you should receive it. In your case, not receiving it is probably due to a config.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
TezWingfield83
Tourist
15 0 1

Hi Bill,

 

Still not found the issue, it makes it tremendously difficult if I cannot see what's being returned when shopify attempts to make the call. Surly there's an event stream somewhere?

 

Taking a screen shot of my dashboard, If the fail rate is at 0.0 (and assuming I have a problem) that should be greater than zero.

wh.png

Their needs to be more tools to understand the problem. If you say 99% of the time it's user error and shopify is sending the request, can I not see a log of this somewhere?

 

Regards,

 

 

HunkyBill
Shopify Expert
4764 54 551

My best advice to you is to reach out to your community then. Not sure what scripting language you are using, but it has users that have handled webhooks before, and probably have written blog posts and Stackoverflow stories about your issue. Try them for advice!

As you well know, Webhooks are nothing new or exotic in Internet computing, and Shopify is nothing but standard issue Webhooks. So like all things scripting, I am sure there something in your setup you are missing, and once you find it, you'll have glory!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
TezWingfield83
Tourist
15 0 1

Hi Bill,

Thanks for the reply.

Yes, I've built a few systems on webhooks, they truly are magnificent.

I'm using .net/c#.

Do we not have access to logs? I could scout around, but if the logs just tells me the exact problem, I can resolve it. I have a tracer running this end, and nothing is coming in.

My last attempt is to remove the method from the app and add it to a serverless pipeline (Azure HTTP func), if that fails, well I'm truly lost. I recently wrote an app for a WMS system using hooks, with the same process/method and that works fine.

 

I guess I'll report back.

 

Regards,

HunkyBill
Shopify Expert
4764 54 551

The puzzle from your Dashboard report is fact none are even reported as being tried. So lets type this out. You install your App, which is all fine and dandy. You mastered oAuth. Your database has a token from a shop (likely your test shop) which you setup in the partner Dashboard with ngrok.io settings directly to your App. I myself use a service allowing me to call me Apps stuff like fizzbuzz.test which map nicely to fizzbuzz.ngrok.io which I setup in my Shopify App dashboard.

Once I am setup, and I navigate to the App and see it come up, usually embedded, and usually Polaris... my Hello World if you will, I then uninstall the App. Shopify fires off the uninstall, I watch my terminal logs where I am running my localhost webserver version of the App, and BOOM. I see the Webhook get processed in real-time.

So simple. But the fact that you are doing ALL that, and seeing nothing, is indeed weird. I cannot speak for C# users, but perhaps someone in that community can get you over the hump.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
TezWingfield83
Tourist
15 0 1

Hi Bill,

It's always great to "rubber duck" the flow.

 

Yes, so I create an app in shopify - fill in the necessary fields.

 

1. Click the app

s-app.png

 2, Select a store

locate-app.png

 3, Click and Install

dav.png

 At this point it goes through all typical OAuth process, On the call back using the redirect uri I begin to create the app/uninstalled webhook.

db-h.png

 I also log the resp

 

h-resp.png

 And I can also see the resp when getting all webhooks for that account

ps-resp.png

The app is most certainly "installed"

app-inst.png

 Looking at the same screenshot, I click the Delete button being the uninstalled process, even tried when clicking into the app.

 

 I've tested my own endpoint to simulate what shopify is attempting to do and it works:

ps-self.png

End result my local server is still running and not being hit:

 

l-serv.png

 

I've used the same hook endpoint stored in hook resp, my config tbl, postman etc... The url works.

 

Other process, ngrok running locally with a developers account - nothing out of the ordinary.

 

Regards,

 

_JB
Shopify Staff
Shopify Staff
836 99 211

Hey @TezWingfield83,

If you provide the id for your app I'll check our logs to confirm the webhook is being sent, and confirm the response we're seeing from your endpoint. Bill's advice is great and there's isn't anything else I'd add, but I can at least confirm the behaviour in our logs to give a bit more confidence while you troubleshoot. The app id is the last set of digits in the URL when you're viewing the app in the partner dashboard.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

TezWingfield83
Tourist
15 0 1

Hi JB, Bill,

 

Thank you.

Here's the Id: 5175689

Regards,

 

_JB
Shopify Staff
Shopify Staff
836 99 211

This is an accepted solution.

@TezWingfield83,

The logs confirm a webhook is indeed firing, but your endpoint is responding with a 503 error. They're being sent to https://[removed].ngrok.io/Shopify/Uninstall . Hopefully that helps with troubleshooting.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

TezWingfield83
Tourist
15 0 1

Hi JB, Bill.

Awesome that's something to go on.

503 Service unavailable implies, I guess more of a network issue. I'm able to hit that endpoint locally using ngrok with no issues.

To confirm a network related issue, I'll aim to deploy a serverless http func to see if that resolves it - just makes it impossible to debug locally.

Thank you for your time all.

I'll report back later.

Regards,

TezWingfield83
Tourist
15 0 1

Hi @HunkyBill @_JB 

 

Thank you again, I know it's been a challenge. I'm pleased it's not a developer mistake, I.E bug / config. 

JB, would it be possible just to confirm whether you're now receiving a 200. I've quickly deployed a serverless func, and can see an execution on my tracer but don't have any logs yet due to a quick temp release to test the theory.

 

Having said that, I'm still not quite sure why shopify cannot reach my ngrok instance. baffling.

 

Regards,

 

HunkyBill
Shopify Expert
4764 54 551

I would still bundle any issues you have with your service as a config problem. Whether it be with ngrok, or other aspects, those all get lumped in... Shopify is sending the webhook. That action generates a non-200 OK response... therefore that is a config issue. But yes, it is also that you have not made a typo of otherwise introduced some kind of bug yourself. Good luck, and hopefully your can sort out your ngrok issues soon!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
_JB
Shopify Staff
Shopify Staff
836 99 211

Hey @TezWingfield83,

Confirmed, I'm seeing 4 200 - OK responses in the past hour. Note that Shopify automatically retries failed webhook deliveries, so some of those may be from previous failed delivery attempts.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

TezWingfield83
Tourist
15 0 1

Hi @HunkyBill 

Thanks for the info, does come off a little iffy/sarcastic haha but appreciate the honesty.

I use the same configuration through various WMS systems, I'm confident in the approach but non the less shall investigate the configuration.

Again, thank you for the time taken.

Regards,

TezWingfield83
Tourist
15 0 1

Hi @_JB 

Fantastic, Thank you.

I truly appreciate the time taken.

Regards,