Discourse not linking the Comments automatically under the articles

WP Rocket should be fine. It’s possible you’ll need to make some adjustments to break the cache on WordPress pages that are displaying Discourse comments. There’s a good suggestion here: WP Discourse comment webhook does not trigger a WP Rocket Cache refresh - #13 by Brandon007. The WP Discourse “ajax load” option is also a reasonable workaround.

This seems like the real problem:
[2024-03-14 06:02:59] comment.ERROR: sync_comments.response_error {"message":"Forbidden","discourse_topic_id":"","wp_post_id":13514,"http_code":403}

That’s saying that Discourse is returning a 403 response (forbidden) when the WP Discourse plugin attempts to pull in comments. (The error is being logged from here: wp-discourse/lib/discourse-comment.php at main · discourse/wp-discourse · GitHub)

It’s a bit of a guess, but this plugin suggests that your WordPress site is behind a proxy:

It’s possible that’s triggering the 403 error on Discourse. Maybe the request headers aren’t configured correctly? It’s not something I know a lot about. But, you might be able to confirm if it’s an issue by publishing a post from WordPress with your Discourse site’s Error Logs page open.

Click this link to get to the error logs page:

I think a 403 response will trigger an entry in the logs. If it does, share the (redacted) error message here.

Thanks! I will try as soon as I come to it.

I also found out that the previous caching seemed to work with plugins GridPane Redis Object Cache and Nginx Helper. So maybe it was even unnecessary from me to install WP Rocket. But deactivating any of them didn’t helped too.

Also comment counting doesn’t work atm. Even when clearing the cache, the number of the newest article stays at 16 (discourse has 18 comments for now)

As mentioned before: the ajax option is activated.

Will do that thing with the log later or tomorrow.

Yes, any of the popular caching plugins should work. Just install one and try to get a sense of what it’s doing. For debugging issues, it might be useful to temporarily disable caching. That way you can confirm that it’s not a cache related issue.

Comment counts are set from the function that’s returning this error:

[2024-03-14 06:02:59] comment.ERROR: sync_comments.response_error {"message":"Forbidden","discourse_topic_id":"","wp_post_id":13514,"http_code":403}

If you are still getting that error, comment counts will not get updated.

Having the Proxy Real IP - 1.1 plugin installed on the site suggests that its server configuration is fairly complex. Maybe check with the person who setup the site to ask for details. You might also consider moving the site to a hosting service that would take care of this kind of thing for you.

I’m less certain than I was yesterday that the issue will show up in the Discourse error logs, but it’s still worth trying.

It’s installed but not activated on our german page, just on our english one. I asked the one who had the page before me about that plugin some weeks ago and just forgot to also deactivate it on the english page. Discourse is just connected to our german page where it is not activated. So I guess it doesn’t has a function atm.

I really wish I would have more of an idea of all these things, as I also experience the wordpress being very slow from time to time and I don’t really get behind all these stuff from just reading around in the internet.

Just to clarify: I’m talking mainly about miasanrot.de / miasanrot.com is not connected to discourse. So this site is working with the normal comment system of Wordpress.

You’re right with your feeling. Published an article with error log open and it doesn’t show up in the error log of discourse.

It’s even worse now: The new article isn’t showing up for people who are not logged into WP. So the page is like frozen.

Update 2: It shows the correct number of comments AND the new article now, but I don’t really know what changed. One blind guess: I deactivated the two caching plugins I mentioned before and just had WP rocket activated. I tried to reactivate the two plugins and nothing changed. Then I updated the article in the editor and it worked. So one of the two plugins (the nginx helper) is saying “Cleans nginx’s fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things.” – so I guess it was this process that now helped to show the page as it should.

I think I can deactivate WP Rocket then, but still there is something not right about the caching and I have the feeling that it could be connected to the Discourse problem.

Your main issue is defenetly something else, but why are you using Nginx-helper? WP Rocket makes static copies and you don’t need another cache for fastcgi and Redis (sure, there is situations when PHP-calls may need caching even there is WP Rocket, but those sites normally don’t use WP Rocket but much more pro-level tools).

But caching means nothing dynamic happends.

It was already installed when I took over this blog. I don’t know why tbh. I just know as soon as I deactivate it, I don’t get the page updated. So yes, somewhere in that direction the problem could be.

Edit: Just made the check now. Deactivated the plugin, no possibility to get the page updated. Activated the plugin and updated an article and the correct number of comments shows up.

A wild guess is that you should then take a peek what wp-config.php is trying to do. Few very first lines may give a hint.

But again. You should disable every plugings and use one of basic theme, like 2020, and then try if Discourse acts as it should. If yes, some of plugings or theme is an issue.

Backup your database first. Disabling plugins and theme may give you unwanted suprise. WP-CLI is worth of googling, if you don’t already have it.

But if it is still fighting against you… hopefully someone gurus here can help.

Anyway — you should consider what plugins you are using and if you really need those.

I plan to do this as soon as I have the time and the traffic is not so big. Atm it’s complicated to find a day where we can put in such a test. But I will do.

One more observation:
When I publish an article directly without publishing it private before (I normally do this when i don’t want to publish directly), discourse connects the topic correctly to the article. (The number of comments shown are still wrong, but the comments are showing under the article)

2 Likes