开发者

Tornado as normal server

开发者 https://www.devze.com 2023-03-09 01:53 出处:网络
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 a

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消