mgeeky/RedWarden

Doesn't work with latest tornado version

ptr0x1 opened this issue · 2 comments

Based on the code looks like this was written for the 4.5 branch of tornado: https://www.tornadoweb.org/en/branch4.5/tcpserver.html

Where the multi-process server takes the following commands:

sockets = bind_sockets(8888)
tornado.process.fork_processes(0)
server = TCPServer()
server.add_sockets(sockets)
IOLoop.current().start()

Where as the latest 6.x branch has it defined this way: https://www.tornadoweb.org/en/stable/tcpserver.html

sockets = bind_sockets(8888)
tornado.process.fork_processes(0)
async def post_fork_main():
    server = TCPServer()
    server.add_sockets(sockets)
    await asyncio.Event().wait()
asyncio.run(post_fork_main())

Furthermore 5.0 removed IOLoop argument.

I tried pinning the tornado version in the requirements for 4.5.3 but even then I get the following error (using just the example config, setting a valid cert and listening only on port 443):

Cannot run in multiple processes: IOLoop instance has already been initialized. You cannot call IOLoop.instance() before calling start_processes()

This is probably related to #14 . The person did not share much detail but I was running into the same stack traces that they shared, which is when I started looking at tornado. If you have a working setup could you share the package versions you are using? Maybe some of the other packages also need to be downgraded. I am testing this on a clean new Ubuntu 20.04 VM, only pip3 and the requirements were installed.

Thanks for all your work on this tool! :)

Hi there @ptr0x1 ! Thank you for a terrific problem outline. Very detailed, striaght to the point, with preliminary analysis & tests done. Awesome!

So, version pinning was the first workaround I was about to mention but you already tried it out. Looks like there's going to be some programmic work required. It's been at least two months since I last time worked with RedWarden so I don't have more recent version.

Currently I'm bit busy with other projects but will try to address this issue next week, hold on a little. Maybe simply updating that core Tornado logic would be enough to get it up & running?

Best regards,
Mariusz

Thanks for the kind words, I've spent some time with it and it turned out to be a fairly quick change to make it work. The simple config I tested worked properly however it did have a weird issue where 'serve_proxy' runs twice per port so some testing will be necessary.

I'll try to figure it out, I'm blaming the threading aspect but can't see what is wrong yet. I've added a bit more detail in the pull request itself.