drewzboto / grunt-connect-proxy

Grunt Connect support for proxying API calls during development
MIT License
424 stars 122 forks source link

Open socket client before server shutdown proxy #76

Closed yamsellem closed 9 years ago

yamsellem commented 9 years ago

When using sockets the following case can occur: — the server starts with the proxy (without error) — a client open a socket through the proxy (without error) — the server is stopped manually — the server is started again — the proxy fails with a Fatal error: connect ECONNREFUSED

This is happening because a client is still trying to connect to the server. The proxy transfers the socket request, but the server is starting, so it does not respond to requests yet.

Handling errors on the http-proxy instance is enough to handle this case. The error is displayed and further calls are properly handled.

matthieubulte commented 9 years ago

The fix looks quite straightforward, I'll check the runtime behaviour later and merge if everything is good.

ruiaraujo commented 9 years ago

@matthieubulte I have tested this but besides a better error message it worked flawlessly with or without the patch.

Since we have updated the http proxy version in the meanwhile, this scenario might have been fixed by them.

TLDR: I think this should be merged.