h2non / toxy

Hackable HTTP proxy for resiliency testing and simulated network conditions
MIT License
2.73k stars 82 forks source link

Nothing works on Node 16 #68

Open mifi opened 2 years ago

mifi commented 2 years ago

This example https://github.com/h2non/toxy/blob/master/examples/bandwidth-limit.js or even this simple code:

const toxy = require('toxy')
const http = require('http');

const proxy = toxy()

const rules = proxy.rules
const poisons = proxy.poisons

proxy
  .forward('http://httpbin.org')

proxy.all('/*')

proxy.listen(3000)
console.log('Server listening on port:', 3000)

...doesn't work.

When connecting with curl:

curl -vvv http://localhost:3000/ 
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.64.1
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection 0

Works fine with node v10.

h2non commented 2 years ago

toxy is no longer actively maintained, I'm sorry. Although, it can be easily adapted to work with node v14+, but it would be quicker to use other maintained solutions out there, such as toxiproxy

mifi commented 2 years ago

Thanks for your fast reply! I also went with toxiproxy. That's a pity, because toxy is a really cool tool, and even seems to support more features than toxyproxy. Maybe you could put a note on top of the readme warning people that it's no longer maintained and not working on latest Node.js, or looking for maintainer, if you are open for someone taking over:)

h2non commented 2 years ago

Right, just done!

stepankuzmin commented 1 year ago

Also stumbled on this. For anyone who is interested, you'd need to add at least one poison for it to work, e.g.:

-proxy.all('/*')
+proxy
+  .all('/*')
+  .poison(poisons.latency(0))