LangGraph error - ReadTimeout: HTTPSConnectionPool(host='mermaid.ink', port=443): Read timed out. (read timeout=10)

에러 발생

langgraph 를 사용해서 노드와 엣지를 설정하고 그래프를 그리려고 하는데 다음과 같이 에러가 발생했다.

ReadTimeout: HTTPSConnectionPool(host='mermaid.ink', port=443): Read timed out. (read timeout=10)

 

에러 내용으로는 누가봐도 타임아웃이 발생해서 연결이 끊긴 것으로 확인되는데 왜 타임아웃이 발생했는지 알 수 있는 방법이 없었다.

그래서 바로 구글 서치를 시작해서 원인이 무엇이고 해결할 수 있는 방법은 무엇인지 찾아보았다.

 

원인 분석

에러를 바탕으로 stack overflow 와 github issue 등 여러 문서들을 찾아보았다.

하지만 여러 레퍼런스를 찾아보니 나와 같은 문제가 발생하는 경우가 다반사인것으로 보였다. 원인이 무엇인지 단정짓기는 어려웠고 mermaid API 서버의 문제라고 하는 사람도 있었고 github 이슈에서는 트래픽이 너무 많아 수동으로 시스템을 정상으로 만들었다고 댓글이 달려있었다.

 

원인을 찾아보면서 확인한 문서는 아래의 참고 레퍼런스에 나열되어있다.

 

해결 방법

결국에는 아직까지 해결되었다는 내용을 찾아볼 수 없었고 해결방법 또한 아직 명확하게 나온 것이 없었다.

 

무려 5시간 전에도 같은 증상이 발생하는 것을 보아하니 아직까지 현재 진행중인 에러인 것으로 보인다.

한 가지 확실한 부분은 내가 사용하는 과정에서 문제가 발생한 것이 아니라 서버의 문제라고 볼 수 있어 서버의 문제를 해결하거나 아니면 다른 방법을 사용하는 수 밖에 없을 것 같다.

 

그래서 어떤 사람은 PNG 파일 말고 ASCII 를 사용해서 보는 방법으로 그래프를 보고 있는 것 같았다. 하지만 확실히 퀄리티는 많이 떨어지긴 하지만 아쉬운대로 보고 싶다면 사용해보면 좋을 것 같다.

# 1. 라이브러리 설치
pip install grandalf

# 2. 그래프 출력
display(Image(graph.get_graph().print_ascii()))

 

아니면 아래와 같이 mermaid 코드를 아래와 같이 출력할 수 있는데
노션과 같은 에디터를 통해서 출력된 코드를 실행하면 다음과 같이 확인해볼 수 있다.

print((graph.get_graph().draw_mermaid()))

출력 결과

---
config:
  flowchart:
    curve: linear
---
graph TD;
	__start__([<p>__start__</p>]):::first
	retriever(retriever)
	__end__([<p>__end__</p>]):::last
	__start__ --> retriever;
	retriever --> __end__;
	classDef default fill:#f2f0ff,line-height:1.2
	classDef first fill-opacity:0
	classDef last fill:#bfb6fc

 

이 코드를 노션에서 확인해본다.

 

정말 확인하고 싶다면 이런 방법으로도 확인해볼 수 있다.

참고 레퍼런스

https://stackoverflow.com/questions/79575640/mermaid-ink-timeout-error-when-using-short-node-name-in-langgraph-diagram

 

Mermaid.ink Timeout Error When Using Short Node Name in langgraph Diagram

I’m using langgraph in a Jupyter notebook to build a simple state machine and then render the graph with Mermaid via mermaid.ink. In one snippet of code, naming the node "A" causes a time...

stackoverflow.com

https://github.com/jihchi/mermaid.ink/issues/521

 

TimeOutError - ValueError - Failed to reach mermaid.ink/ API while trying to render · Issue #521 · jihchi/mermaid.ink

This is code from the free langgraph-course of the langchain academy: import random from IPython.display import Image, display from langgraph.graph import StateGraph, START, END from typing import ...

github.com

https://github.com/jihchi/mermaid.ink/issues/505

 

ReadTimeoutError When Accessing Mermaid.ink · Issue #505 · jihchi/mermaid.ink

When attempting to generate a visualization using graph.get_graph().draw_mermaid_png(), the request to https://mermaid.ink times out after 10 seconds, causing a ReadTimeoutError. TimeoutError: The ...

github.com

https://github.com/jihchi/mermaid.ink/issues/491#issuecomment-2724318198

 

It takes more than 5 minutes to display the image · Issue #491 · jihchi/mermaid.ink

I am using make.com to set a url and it took more than 5 minutes ti generate this one : https://mermaid.ink/img/eyJjb2RlIjogImZsb3djaGFydCBURFxuXHRUYXNrW1wiVHdpdHRlciBDb250ZW50IENyZWF0aW9uXFxuVHJhb...

github.com