dify_plugin exists error when reading handshake event data(json read error from an inner lib) #151

Closed
opened 2026-02-16 00:20:11 -05:00 by yindo · 1 comment
Owner

Originally created by @freezetheflame on GitHub (Jul 2, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.0.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I am working on a dify-tool plugin with self-hosted dify locally, it works well when I implement the first functionality, but after I added some new features( I'm not sure whether it's right) ,it came up with such an error:

ERROR:dify_plugin.core.server.tcp.request_reader:An error occurred while parsing the data: b'handshake failed, invalid key'
Traceback (most recent call last):
  File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 192, in _read_stream
    data = TypeAdapter(dict[str, Any]).validate_json(line)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\pydantic\type_adapter.py", line 468, in validate_json
    return self.validator.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for dict[str,any]
  Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value=b'handshake failed, invalid key', input_type=bytes]
    For further information visit https://errors.pydantic.dev/2.11/v/json_invalid
ERROR:dify_plugin.core.server.tcp.request_reader:Failed to read data from localhost:5003
Traceback (most recent call last):
  File "C:\Users\*******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 169, in _read_stream
    raise Exception("Connection is closed")
Exception: Connection is closed

and I have no idea what's wrong , after I check all my yaml config

✔️ Expected Behavior

connection is good and my plugin can work well or report some bugs from specific file

Actual Behavior

{"event": "log", "data": {"level": "INFO", "message": "Installed tool: myapp", "timestamp": 1751439157.929936}}
INFO:dify_plugin.plugin:Installed tool: myapp
ERROR:dify_plugin.core.server.tcp.request_reader:An error occurred while parsing the data: b'handshake failed, invalid key'
Traceback (most recent call last):
  File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 192, in _read_stream
    data = TypeAdapter(dict[str, Any]).validate_json(line)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\pydantic\type_adapter.py", line 468, in validate_json
    return self.validator.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for dict[str,any]
  Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value=b'handshake failed, invalid key', input_type=bytes]
    For further information visit https://errors.pydantic.dev/2.11/v/json_invalid
ERROR:dify_plugin.core.server.tcp.request_reader:Failed to read data from localhost:5003
Traceback (most recent call last):
  File "C:\Users\*******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 169, in _read_stream
    raise Exception("Connection is closed")
Exception: Connection is closed
Originally created by @freezetheflame on GitHub (Jul 2, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.0.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I am working on a dify-tool plugin with self-hosted dify locally, it works well when I implement the first functionality, but after I added some new features( I'm not sure whether it's right) ,it came up with such an error: ``` ERROR:dify_plugin.core.server.tcp.request_reader:An error occurred while parsing the data: b'handshake failed, invalid key' Traceback (most recent call last): File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 192, in _read_stream data = TypeAdapter(dict[str, Any]).validate_json(line) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\pydantic\type_adapter.py", line 468, in validate_json return self.validator.validate_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 1 validation error for dict[str,any] Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value=b'handshake failed, invalid key', input_type=bytes] For further information visit https://errors.pydantic.dev/2.11/v/json_invalid ERROR:dify_plugin.core.server.tcp.request_reader:Failed to read data from localhost:5003 Traceback (most recent call last): File "C:\Users\*******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 169, in _read_stream raise Exception("Connection is closed") Exception: Connection is closed ``` and I have no idea what's wrong , after I check all my yaml config ### ✔️ Expected Behavior connection is good and my plugin can work well or report some bugs from specific file ### ❌ Actual Behavior ``` {"event": "log", "data": {"level": "INFO", "message": "Installed tool: myapp", "timestamp": 1751439157.929936}} INFO:dify_plugin.plugin:Installed tool: myapp ERROR:dify_plugin.core.server.tcp.request_reader:An error occurred while parsing the data: b'handshake failed, invalid key' Traceback (most recent call last): File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 192, in _read_stream data = TypeAdapter(dict[str, Any]).validate_json(line) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\******\anaconda3\envs\myapp\Lib\site-packages\pydantic\type_adapter.py", line 468, in validate_json return self.validator.validate_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 1 validation error for dict[str,any] Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value=b'handshake failed, invalid key', input_type=bytes] For further information visit https://errors.pydantic.dev/2.11/v/json_invalid ERROR:dify_plugin.core.server.tcp.request_reader:Failed to read data from localhost:5003 Traceback (most recent call last): File "C:\Users\*******\anaconda3\envs\myapp\Lib\site-packages\dify_plugin\core\server\tcp\request_reader.py", line 169, in _read_stream raise Exception("Connection is closed") Exception: Connection is closed ```
yindo closed this issue 2026-02-16 00:20:11 -05:00
Author
Owner

@freezetheflame commented on GitHub (Jul 2, 2025):

I forgot to check the debug settings as the debug key has changed( will the reflash of the page change the key? I didn't know this from the document). After I reset the debug key ,it work well again.

@freezetheflame commented on GitHub (Jul 2, 2025): I forgot to check the debug settings as **the debug key has changed**( will the reflash of the page change the key? I didn't know this from the document). After I reset the debug key ,it work well again.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#151