Search code examples
pythonherokuwebsockettornadosockjs

python-tornado chatdemo on heroku


I am new to python-tornado. I tried the chat demo on tornado.org. It works perfectly on my localhost; however, After deploying it onto heroku, I can't get the message(chat with 2 browsers) only if I refresh the browser.The demo site is here https://tornadochat2.herokuapp.com and the demo code:https://github.com/tornadoweb/tornado/blob/stable/demos/chat/chatdemo.py My Procfile is as below web: python chat.py --port=$PORT I have no idea what's going on of it


Solution

  • It doesn't work because you're accessing it using https:// but you're trying to load jquery using http://. If you check out your browser's error console you'll see the error that's preventing jquery library to load. This is known as Mixed Content.

    Noltice that it works if you go to http://tornadochat2.herokuapp.com/ (not using https).

    In order to make it work, just change this html code in templates/index.html:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
    

    for:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>