coralproject / talk

A better commenting experience from Vox Media
https://coralproject.net
Other
1.89k stars 355 forks source link

Story title not available #4368

Closed XIYO closed 11 months ago

XIYO commented 11 months ago

I have run it using Docker. Notably,

I am running it on Docker in Windows 11. I am testing it by building Jekyll, testing it on localhost:400.

Did I configure something incorrectly?

docker-compose.yaml

version: "2"
services:
  talk:
    image: coralproject/talk:7
    restart: always
    ports:
      - "127.0.0.1:5000:5000"
    depends_on:
      - mongo
      - redis
    environment:
      - MONGODB_URI=mongodb://mongo:27017/coral
      - REDIS_URI=redis://redis:6379
      # - SIGNING_SECRET=${SIGNING_SECRET}
      - SIGNING_SECRET="ovyatP1FvjKBw2E1LiFPvu1msOGXTLnjmqPw6tIQZQHZzauZuPFkQIBRkXVZJzBr"
  mongo:
    image: mongo:4.2
    volumes:
      - ./data/mongo:/data/db
  redis:
    image: redis:3.2
    volumes:
      - ./data/redis:/data

javascript

<div id="coral_thread"></div>
    <script type="text/javascript">
      (function() {
          var d = document, s = d.createElement('script');
          s.src = 'http://localhost:5000/assets/js/embed.js';
          s.async = false;
          s.defer = true;
          s.onload = function() {
              Coral.createStreamEmbed({
                  id: "coral_thread",
                  autoRender: true,
                  rootURL: 'http://localhost:5000',
                  // Uncomment these lines and replace with the ID of the
                  // story's ID and URL from your CMS to provide the
                  // tightest integration. Refer to our documentation at
                  // https://docs.coralproject.net for all the configuration
                  // options.
                  // storyID: '${storyID}',
                  // storyURL: '${storyURL}',
              });
          };
          (d.head || d.body).appendChild(s);
      })();
    </script>

image image image

XIYO commented 11 months ago

I found the cause of the problem.

When running the talk service in Docker, domains like localhost, 127.0.0.1 cannot fetch the proper metadata during local testing.

You should test with a path that can be accessed clearly even within Docker, like http://host.docker.internal:4000/ (in my case, it's a blog).

host.docker.internal is automatically declared in the hosts file when Docker is installed.

Is this the only way to access it due to structural reasons?

error log

{"name":"coral","hostname":"e37d3c467b52","pid":1,"jobName":"scraper","jobID":"01020167-1a27-420b-8486-dbdf7b6c8cc7:dc32b511-a44c-454c-998c-00bfdd326c46","attemptsMade":4,"tenantID":"01020167-1a27-420b-8486-dbdf7b6c8cc7","level":50,"err":{"message":"SCRAPE_FAILED: request to http://localhost:4000/posts/web/jekyll-build-on-docker failed, reason: connect ECONNREFUSED 127.0.0.1:4000","name":"ScrapeFailed","stack":"Scraper.download (src/core/server/services/stories/scraper/scraper.ts:138:13)\nrunMicrotasks (<anonymous>)\nScraper.scrape (src/core/server/services/stories/scraper/scraper.ts:145:18)\nObject.scrape (src/core/server/services/stories/scraper/scraper.ts:218:20)\nTask.processor (src/core/server/queue/tasks/scraper.ts:44:5)\nQueue.<anonymous> (src/core/server/queue/Task.ts:116:28)\n","id":"74945e90-65e9-11ee-a76d-5d0b77e3c447","context":{"pub":{"url":"http://localhost:4000/posts/web/jekyll-build-on-docker"},"pvt":{}},"originalError":{"message":"request to http://localhost:4000/posts/web/jekyll-build-on-docker failed, reason: connect ECONNREFUSED 127.0.0.1:4000","name":"FetchError","stack":"ClientRequest.<anonymous> (node_modules/node-fetch/lib/index.js:1461:11)\n"}},"took":9,"msg":"job failed to process","time":"2023-10-08T14:46:25.275Z","src":{"file":"/usr/src/app/src/core/server/queue/Task.ts","line":126},"v":0}

solution

change domain

image