Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using diagrams with a local Kroki instance #1361

Closed
a-bronx opened this issue May 22, 2023 · 6 comments
Closed

Error when using diagrams with a local Kroki instance #1361

a-bronx opened this issue May 22, 2023 · 6 comments
Labels

Comments

@a-bronx
Copy link

a-bronx commented May 22, 2023

Observed vs. expected behavior

An Asciidoc document includes a simple Mermaid diagram:

= Test diagrams

[mermaid, svg]
----
gitGraph
  commit
  commit
----

A local Kroki server is running on http://localhost:8000 (in a Podman container). The server is independently (using a VS Code plugin) confirmed to be functional and producing the diagrams.

The IDEA plugin is configured to use the Kroki server instead of a public server:

image

Expected: the diagram is shwon in the preview.
Observed: an Error 503: Connection refused: /127.0.0.1:8002 string instead of a diagram:

image

Environment

Plugin Version: 0.38.13

IntelliJ IDEA 2023.1.2 (Community Edition)
Build #IC-231.9011.34, built on May 15, 2023
Runtime version: 17.0.6+10-b829.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 750M
Cores: 16
Non-Bundled Plugins:
org.asciidoctor.intellij.asciidoc (0.38.13)

Kotlin: 231-1.8.21-IJ9011.34


P.S. Also, looks like the IdeaJ plugin does not respect diagram-server-* attributes defined in the .asciidoctotconfig.adoc, probably should be a separate issue.

@a-bronx a-bronx added the bug label May 22, 2023
@ahus1
Copy link
Contributor

ahus1 commented May 22, 2023

Thanks for reporting this. I have to admit I've never used it this way myself. Please provide the details on how you started Kroki via podman.

BTW: I'm a bit confused that one URL notes "8000", while another displays "8002" in the error message. Hm.

@a-bronx
Copy link
Author

a-bronx commented May 22, 2023

I used the Kroki's own instructions: https://docs.kroki.io/kroki/setup/use-docker-or-podman/ , following them exactly.

Yes, the offset between the configured and queried ports is what I noticed immediately too.

I tried to use port 7998 in hope it will hit 8000, and it looks like it made some request, but the diagram was not shown, instead I've got a "missing image" icon:

image

When I use a public Kroki server instead, I see the diagram just fine:

image

@a-bronx
Copy link
Author

a-bronx commented May 26, 2023

The issue is resolved -- actually it was a wrong Kroki configuration on my side. I finally noticed that the default yuzutech/kroki image does not include Mermaid diagram server by default, but requires to run a "companion" container (yuzutech/kroki-mermaid) which listens to the port 8002. And it looks like the VS Code extension continued using the online server (either falling back, or ignoring the config), which gave me a perception of a working local server and confused me.

After composing and running both containers, diagrams finally appeared in the preview.

Here is a compose.yml file that made it working:

services:
  kroki:
    image: yuzutech/kroki:latest
    depends_on:
      - mermaid
    environment:
      - KROKI_MERMAID_HOST=mermaid
    ports:
      - "8000:8000"
  mermaid:
    image: yuzutech/kroki-mermaid:latest
    expose:
      - "8002"

@a-bronx a-bronx closed this as completed May 26, 2023
@ahus1
Copy link
Contributor

ahus1 commented May 27, 2023

Interesting, thanks you for continuing to investigate it.

BTW, if the only diagrams you're using are Mermaid diagrams, the AsciiDoc plugin for IntelliJ includes an experimental support for Mermaid diagrams out of the box. I seems to works ok, although not all feature might work at the moment - see #1280.

You can enable it in the plugin's settings. I'd be happy to hear your feedback about it.

image

@a-bronx
Copy link
Author

a-bronx commented May 27, 2023

I need Mermaid only for gitGraph diagrams, other than that I prefer PlantUML.

BTW, why is the plugin not attempt using the diagram-server-url or kroki-server-url attributes in the .asciidoctorconfig.adoc file? Is it by design? What is a recommended way to force everyone in a team to use a specific Kroki server (due to compliance policy) without asking them to manually conifgure the plugin?

@ahus1
Copy link
Contributor

ahus1 commented May 28, 2023

For PlantUML, you could use the embedded asciidoctor-diagram - this works well with the built-in Mermaid Diagrams. My previous comment was wrong.

The current behavior is that one Kroki is enabled, a setting of kroki-server-url would override the Kroki server URL. If you want the current behavior to change, this would require a new ticket to discuss how this should work in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants