How can I troubleshoot Discourse comments embedding feature?

Hi,

I’ve been trying for a while to embed Discourse comments on another site but still haven’t been able to make it work. I started following the instructions on this blog: http://eviltrout.com/2014/01/22/embedding-discourse.html and later on I found other issues, which I was able to fix with guidance from topics on this forum.

I’m now at the stage where I think everything is set up correctly, but for some reason topics don’t get created on the Discourse side (when visiting a page on the client site, the embedded iframe only shows “Loading discussion”). I’ve double-checked (dozens of times actually) the embed settings on Discourse, the embed snippet on the client site (including the canonical URLs), logs, etc and couldn’t find anything wrong, so I started looking into something on our deployment setup.

I just wanted to clarify how the embedding works so I can investigate a bit further. My understanding is that whenever a user visits a page on the blog or site that embeds the comments, a request is made to Discourse, which will pull the referring page contents and create a topic on the fly if it does not exist (my site does not have an RSS feed).

My questions are:

  • Is my assumption on how the embedding works correct?
  • How could I debug if indeed Discourse is having trouble creating the topics from the remote site?

Apologies if this is somewhat obvious but I’m not familiar with Discourse or Rails

Many thanks in advance

1 Like

Can you provide a screenshot to your Discourse embedding settings? What is powering the backend of your blog/site? Is it static html (from a generator) or WordPress or Ghost?

@purldator here are my embed settings (sorry, I can’t embed images or link to them):

  • embeddable hosts: ddhstaging.satapps.org
  • feed polling enabled: {unchecked}
  • feed polling url: {blank}
  • embed by username: ddhdatasets
  • embed username key from feed: {blank}
  • embed category: Data Discovery Hub Datasets
  • embed post limit: 100
  • embed truncate: {unchecked}
  • embed whitelist selector: {blank}
  • embed blacklist selector: {blank}

My site is a data catalog based on CKAN , pages are generated from templates. Here’s what the Discourse snippet looks like on this page:

  <div id="discourse-comments"></div>

<script type="text/javascript">
  var discourseUrl = 'http://forumstaging.satapps.org/',
      discourseEmbedUrl = 'http://ddhstaging.satapps.org/dataset/473cdee9-565c-4a9b-99a8-e8c836837086';

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
      d.src = discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
  })();
</script>

Any pointers will be greatly appreciated.

Any pointers or ideas here would be greatly appreciated.

The rails log shows that the request is received correctly:

Started GET "/embed/comments?embed_url=http%3A%2F%2Fddhstaging.satapps.org%2Fdataset%2F473cdee9-565c-4a9b-99a8-e8c836837086" for 165.254.84.238 a
t 2015-06-24 15:14:27 +0000
Processing by EmbedController#comments as HTML
  Parameters: {"embed_url"=>"http://ddhstaging.satapps.org/dataset/473cdee9-565c-4a9b-99a8-e8c836837086"}
  Rendered embed/loading.html.erb within layouts/embed (0.9ms)
Completed 200 OK in 22ms (Views: 3.1ms | ActiveRecord: 5.9ms)

But nothing happens from there, no topics are created and on the client site the iframe keeps refreshing to the same Loading Discussion page. On the server, the topic_embeds table is empty.

I’ve tracked all the code up until topic_embed.rb where the remote contents should get pulled, but looking at the traffic on the server it doesn’t seem that the contents are being requested, so something is failing before.

Any ideas on what could that be?

I’m using v1.4.0.beta3 +55

Many thanks,

1 Like

It seems that the following change broke embedding:

https://github.com/discourse/discourse/commit/ae277e28a64840433141f8085ab9a080ebce5ef2

Embedding was working before on talk.beta.nyc and data.beta.nyc before this change.

@eviltrout, I noticed that fishtank.eviltrout.com is on Discourse 1.4.0.beta1 which predates this change. Will it still work if its upgraded to the latest beta?

FYI, talk.beta.nyc is running on v1.4.0.beta3 +71.

Thanks!

P.S. @amercader, fancy seeing you here :wink:

1 Like

I don’t think so… http://discourse.codinghorror.com is on 1.4 beta 3 and as you can see the comments are embedded fine there on http://blog.codinghorror.com when you drill through to a blog entry.

If its not too much of a bother, can you create a new test blog post on blog.codinghorror.com?

I noticed that old embedded posts were showing up properly, but when you try to create a new embed, it fails.

Do you see these error log entries too? Open the page with the comments on Chrome with the JS console open and I see them come up after some time.

Yes, I do see them. It only happens in Chrome, Firefox seems to work fine.

Not sure if it is related to the topics not being created on the Discourse site though.

1 Like

I can confirm that rebuilding the Discourse site from scratch targeting v1.4.0.beta1 fixes the embedding. So it seems like some sort of regression has happened on the meantime (probably what @jqnatividad mentions).

Yep @nigelb, @amercader, I can confirm that we’re getting the same errors ourselves.

It’s good to know that embedding works again when using 1.4.0beta1.

Hi, I can confirm too:

  • v1.4.0.beta1 is working fine
  • v1.4.0.beta3 does not create the topics automatically

Unfortunately, I cannot seem to be able to reproduce the JS errors.

Hi there.
How do I roll back the update? I have searching but not much luck.

Thanks

You can’t do the downgrade easily because database changes occurred between beta1 and beta3.
You’ll have to restore a database backup prior to the upgrade if you can.

Anyway, to install a fixed version of discourse, you can add the following lines in your container.yml file:

params:
  version: v1.4.0.beta1

I’m looking at this today. Hopefully I’ll have a solution soon.

Okay sorry guys! There was indeed a bug here. It was serious enough that I’ve updated the latest beta to include it too. So if you are tracking beta just upgrade and you’ll get the patch.

https://github.com/discourse/discourse/commit/008dd967217f844c1ad0eb989030c6250d673b69

4 Likes

Where is our

5 Likes