-
Notifications
You must be signed in to change notification settings - Fork 1k
sse_client blocks indefinitely when server has incorrect base URL #447
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
Comments
@Kudryavkaz I was able to replicate this issue ![]() The issue in the screenshot I've added must be fixed, as the exception is not handled properly as you've mentioned. @Kudryavkaz But the above client code, when incorrect URL is added, quits with unhandled error as mentioned in this comment. It is not blocked indefinitely. Can please provide more information about this indefinite block? |
@kavinkumar807 Thank you for your reply. If you start the example MCP server locally and connect the MCP client to "localhost:xxxx", you will not be able to reproduce this issue. You should start the example MCP server on a remote server, and then use the MCP client to connect to that remote server. "zhangfish.top" is my remote server, and I ran this command on it: |
@Kudryavkaz Debugging the unhandled exception issue. Shall I use your endpoint to test? |
@kavinkumar807 Sure, endpoint is "http://zhangfish.top:8080/sse" |
@Kudryavkaz Thanks |
@Kudryavkaz I could see there are two issue when I was debugging,
![]() Logs @dsp-ant @jspahrsummers the endpoint_url has to be |
#410 seems like this issue is related to this. Adding here for reference |
On further debugging as I've mentioned in the above comment the first point handling exception must be fixed, handling exception gracefully and quitting the client. But feel free to ignore the second point, that's my misunderstanding.
@Kudryavkaz Here the baseUrl for the transport is added intentionally to demonstrate the indefinite blocking scenario right? |
@kavinkumar807 yes. |
@Kudryavkaz Raised PR #500 for the above issue. Cc: @dsp-ant @jspahrsummers @nick-merrill @Kludex @jerome3o-anthropic Note: adding the above people in cc from top contributors as I'm not sure who is the maintainer. |
Describe the bug
When using the
sse_client
function to connect to a remote MCP server, if the MCP server sets an incorrect base URL (like http://localhost:8080), thesse_client
will raise an exception in the following code:python-sdk/src/mcp/client/sse.py
Line 81 in c2ca8e0
The
read_stream_writer
then sends this exception to theread_stream
:python-sdk/src/mcp/client/sse.py
Line 107 in c2ca8e0
However, since the
read_stream
has not been yielded yet, the exception will never be received.As a result, the
sse_client
will be blocked indefinitely.To Reproduce
Expected behavior
The sse_client should raise an exception and exit gracefully.
Logs
None
Additional context
None
The text was updated successfully, but these errors were encountered: