Skip to content

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client #289

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

Closed
zach-blumenfeld opened this issue Apr 9, 2025 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@zach-blumenfeld
Copy link

Describe the bug
Error Connecting. Results in persistent issues requiring server reboot. This is inconsistent. It works fine sometimes other times when my colleagues try and connect it creates this error then no one can connect and I need to reboot the inspector server.

To Reproduce
I use the below setup on Google Cloud VM with Google MCP toolbox.

#install git
sudo apt install git-all

#sudo su 'cause I'm lazy.... then make directories
sudo su
mkdir /ai
cd /ai

# get the things
export VERSION=0.3.0
curl -O https://storage.googleapis.com/genai-toolbox/v$VERSION/linux/amd64/toolbox
chmod +x toolbox
git clone https://github.com/neo4j-examples/neo4j-gcp-vertex-ai-langchain.git

# create a new screen so it isn't tied to your ssh session
screen -S mcp

#start mcp server
./toolbox --tools-file neo4j-gcp-vertex-ai-langchain/toolbox-companies/tools.yaml -a 0.0.0.0

detach from screen using Ctrl+a d

Now you will have the MCP server you can connect to on http://xxxxxxxxxx:5000/mcp/sse
. For MCP inspector:

#install npm
sudo apt install npm

#I like my screens....
screen -S inspector

#run
npx @modelcontextprotocol/inspector

Expected behavior
For the connection to work fine.

Logs

Received message for sessionId 3e2e5cf9-695e-4a8e-8d5c-842425b35e7b
Received message for sessionId 3e2e5cf9-695e-4a8e-8d5c-842425b35e7b
New SSE connection
Query parameters: { transportType: 'sse', url: 'http://xxxxxxx:5000/mcp/sse' }
SSE transport: url=http://xxxxxxxxx:5000/mcp/sse, headers=Accept
Connected to SSE transport
Connected MCP client to backing server transport
Created web app transport
Created web app transport
Set up MCP proxy
Received message for sessionId 3e2e5cf9-695e-4a8e-8d5c-842425b35e7b
Error in /message route: Error: SSE connection not established
    at SSEServerTransport.handlePostMessage (file:///root/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js:53:19)
    at file:///root/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:130:25
    at Layer.handle [as handle_request] (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/layer.js:95:5)
    at next (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/route.js:149:13)
    at Route.dispatch (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/route.js:119:3)
    at Layer.handle [as handle_request] (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/layer.js:95:5)
    at /root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/index.js:346:12)
    at next (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/router/index.js:280:10)
    at cors (/root/.npm/_npx/5a9d879542beca3a/node_modules/cors/lib/index.js:188:7)
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:648:11)
    at ServerResponse.header (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/response.js:794:10)
    at ServerResponse.json (/root/.npm/_npx/5a9d879542beca3a/node_modules/express/lib/response.js:275:10)
    at file:///root/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:134:25
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_HTTP_HEADERS_SENT'
}
@zach-blumenfeld zach-blumenfeld added the bug Something isn't working label Apr 9, 2025
@pulkitsharma07
Copy link
Contributor

#290

@cliffhall
Copy link
Contributor

@zach-blumenfeld Thanks for this. Going to try and get a 0.8.3 out today or tomorrow that has #290 in it, which fixes this issue.

@cliffhall cliffhall added the duplicate This issue or pull request already exists label Apr 9, 2025
@cliffhall
Copy link
Contributor

Duplicate of #273

@cliffhall cliffhall marked this as a duplicate of #273 Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants