strapi-community / jekyll-strapi

Jekyll plugin to retrieve content from any Strapi API.
https://strapi.io
MIT License
57 stars 30 forks source link

Address not available on Dev Jekyll build using Docker Compose #17

Closed oDinZu closed 2 years ago

oDinZu commented 3 years ago

Error

Jekyll Strapi: Fetching entries from http://localhost:1337/testdata?_limit=10000
jekyll-serve_1  | /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `initialize': Failed to open TCP connection to localhost:1337 (Address not available - connect(2) for "localhost" port 1337) (Errno::EADDRNOTAVAIL)

Jekyll Version: 4.2.0

Viewing from web browser locally, I see:

http://localhost:1337/posts

id | 2
title | "Title is long enough now"
published_at | "2021-07-29T23:12:33.002Z"
created_at | "2021-07-29T23:05:14.623Z"
updated_at | "2021-07-29T23:12:33.014Z"

Jekyll Layout:

<!-- This loops through the Strapi posts -->
{%- if strapi.collections.posts.size > 0 -%}
      <ul>
        {%- for post in strapi.collections.posts -%}
        <li>
          {{ post.name }}
        </li>
        {%- endfor -%}
      </ul>
  {%- endif -%}

Jekyll Config

# Strapi dashboard integration
strapi:
    # Your API endpoint (optional, default to http://localhost:1337)
    endpoint: http://localhost:1337
    # Collections, key is used to access in the strapi.collections
    # template variable
    collections:
        # Example for a "posts" collection
        posts:
            type: posts

Jekyll Gemfile

group :jekyll_plugins do
   gem "jekyll-feed", "~> 0.12"
   gem "jekyll-strapi", "~> 0.1.3"
end
oDinZu commented 3 years ago

Update:

oDinZu commented 3 years ago
jekyll-serve_1  |      Jekyll Strapi: Fetching entries from http://localhost:1337/articles?_limit=10000
jekyll-serve_1  |   Liquid Exception: Failed to open TCP connection to localhost:1337 (Address not available - connect(2) for "localhost" port 1337) in /_layouts/journals.html
jekyll-serve_1  | /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `initialize': Failed to open TCP connection to localhost:1337 (Address not available - connect(2) for "localhost" port 1337) (Errno::EADDRNOTAVAIL)
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `open'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:958:in `connect'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:932:in `start'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:606:in `start'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:481:in `get_response'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-strapi-0.1.3/lib/jekyll/strapi/collection.rb:26:in `each'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-strapi-0.1.3/lib/jekyll/strapi/drops.rb:33:in `to_liquid'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:49:in `block in evaluate'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `each_index'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `evaluate'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/context.rb:159:in `evaluate'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:130:in `collection_segment'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:74:in `render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:36:in `render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:127:in `render_liquid'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:196:in `render_layout'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:159:in `place_in_layouts'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:89:in `render_document'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:63:in `run'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:523:in `render_regenerated'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:516:in `block in render_pages'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:515:in `each'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:515:in `render_pages'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:202:in `render'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:76:in `process'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:28:in `process_site'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/commands/build.rb:65:in `build'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/commands/build.rb:36:in `process'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:89:in `block in process_with_graceful_fail'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:89:in `each'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:89:in `process_with_graceful_fail'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/exe/jekyll:15:in `<top (required)>'
jekyll-serve_1  |   from /usr/local/bundle/bin/jekyll:29:in `load'
jekyll-serve_1  |   from /usr/local/bundle/bin/jekyll:29:in `<main>'
jekyll-serve_1  | /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `initialize': Address not available - connect(2) for "localhost" port 1337 (Errno::EADDRNOTAVAIL)
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `open'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:958:in `connect'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:932:in `start'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:606:in `start'
jekyll-serve_1  |   from /usr/local/lib/ruby/2.7.0/net/http.rb:481:in `get_response'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-strapi-0.1.3/lib/jekyll/strapi/collection.rb:26:in `each'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-strapi-0.1.3/lib/jekyll/strapi/drops.rb:33:in `to_liquid'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:49:in `block in evaluate'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `each_index'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `evaluate'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/context.rb:159:in `evaluate'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:130:in `collection_segment'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:74:in `render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
jekyll-serve_1  |   from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/liquid_renderer/file.rb:36:in `render!'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:127:in `render_liquid'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:196:in `render_layout'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:159:in `place_in_layouts'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:89:in `render_document'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/renderer.rb:63:in `run'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:523:in `render_regenerated'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:516:in `block in render_pages'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:515:in `each'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:515:in `render_pages'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:202:in `render'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/site.rb:76:in `process'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:28:in `process_site'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/commands/build.rb:65:in `build'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/commands/build.rb:36:in `process'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:89:in `block in process_with_graceful_fail'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:89:in `each'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/command.rb:89:in `process_with_graceful_fail'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
jekyll-serve_1  |   from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
jekyll-serve_1  |   from /usr/gem/gems/jekyll-4.0.1/exe/jekyll:15:in `<top (required)>'
jekyll-serve_1  |   from /usr/local/bundle/bin/jekyll:29:in `load'
jekyll-serve_1  |   from /usr/local/bundle/bin/jekyll:29:in `<main>'
oDinZu commented 3 years ago

Yeah, i have been trying to debug this for 3 days now :(

I have come to the conclusion it must be the plugin; the connection is open, yet it is being refused..maybe because of JSON formatting error?

telnet localhost 1337

Jekyll Version: 4.2.0 Strapi-jekyll Version: 0.1.3 Docker version 20.10.7, build f0df350 Docker Compose version 3.9

I got another plugin called: jekyll-get-json to work with a file.json file, but it doesn't work for url/posts. https://github.com/brockfanning/jekyll-get-json/issues/10#issue-957328411

What is the main difference with strapi-jekyll and jekyll-get-json?

oDinZu commented 3 years ago

Okay, i have mitigated the problem down to my Strapi CMS localhost. It is my problem, but still am unsure why. I tested with a live demo with strapi api and it worked..Only thing I have not tested is building strapi locally without docker-compose

oDinZu commented 2 years ago

I am currently working on a my own solution (jekyll-strapi) plugin and will share it at a later date.