简体   繁体   中英

Tornado as normal server

How to listen for the connections on Tornado Web Server coming not from local network? Default it listening only for connection from localhost. I have tried tips from Django to start it listening on address 0.0.0.0 but this doesn't work.

Some simple code:

server = tornado.httpserver.HTTPServer(application)
server.listen(8000, '0.0.0.0')

BY default the tornado httpserver will listen on the specified port for all net interfaces (IP addresses). So, passing the port only should work fine.

You also need to be sure to start the ioloop instance that the server is using:

http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8000)
tornado.ioloop.IOLoop.instance().start()

The tornado docs are very good.

I found this question while trying trying to diagnose a similar issue (tornado server running on computer A, inaccessible from computer B).

I eventually figured it out, I needed to open the port on computer A's firewall.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM