Tornado (webserver with WebSocket)

Questions and comments specific to a particular plugin should go here.
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: Tornado (webserver with WebSocket)

Post by techoguy » Fri Jan 31, 2014 11:58 pm

Hi Pako,
This is awesome, i've been wanting to make/have something like this.

Hopefully in the near future I can use this to integrate the Insteon plugin and my SONOS plugin to have a web interface. Ultimately it can allow me to create a GUI for my home control and status.

Thanks for the great work!
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!

User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: Tornado (webserver with WebSocket)

Post by Livin » Sat Feb 01, 2014 12:43 am

Pako and community...

While this is very cool, many of us have a multi-faceted home theater and home automation. And every app seems to have its own web UI - which makes things very disjointed. I'm not a fan of customer building everything from scratch, it has bit me too many times when apps change APIs, etc.

My suggestion...

Utilize what Pako has built and integrate into an existing framework that is being actively developed and already has MANY other apps fully integrated.

There are a few but the most actively developed is HTPC Manager...
http://htpc.io
... which already has XBMC, Sick Beard, SABnzbd, CouchPotato, Transmission -- and adding others like Deluge, NZBget, etc

Anyway, I'd love to see an EventGhost module for HTPC Manager so I can have an integrated UI for launching Macros.

I just don't see a reason/need to yet another Web framework when so many others already exist and are well supported.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system

leothlon
Experienced User
Posts: 59
Joined: Tue Dec 17, 2013 6:29 pm

Re: Tornado (webserver with WebSocket)

Post by leothlon » Mon Feb 03, 2014 7:33 pm

Does tornado support php? The other webserver plugin dont seem to.

My problem is that i want to get info from xbmc json-rpc, but i cant do an ajax request as it gives same-origin-policy error. so i was able to set a php proxy page (the php page fetches the data from xbmc, as it is serverside script it dont get same-origin-policy error) then i use ajax request to get the data from the proxy page.
However it dont seem like the eventghost webservers support php...
Does tornado have any kind of server side scripting? so that i can make a proxypage somehow?

i basicly want a proxy page with this functionality:

Code: Select all

<?php
$file = file_get_contents($_GET['requrl']);
echo $file;
?>
What this means is i can use the proxy page like: myWebserver.com/proxy.php?&requrl=www.google.com
And this would get the data from the requrl (www.google.com) and show it to me.

leothlon
Experienced User
Posts: 59
Joined: Tue Dec 17, 2013 6:29 pm

Re: Tornado (webserver with WebSocket)

Post by leothlon » Wed Feb 05, 2014 1:13 pm

is there realy no way of doing this?
Should i abandon my wishes to control and get data from xbmc with my tornado webserver completly?
i got tornado running on localhost:8085 and xbmc on localhost:8083,
Why cant i do ajax requests from tornado to xbmc, they are on the same computer why does it give same origin-policy-error?..

the url works when posted in a browser, but when fetched with ajax it doesn't work? why cant javascript emulate the browser request?

I've been looking for a solution over a week now and there just dont seem to be any way to get it to work?

regystro
Posts: 2
Joined: Wed Feb 05, 2014 4:27 pm

Any chance to get HTTPS / SSL?

Post by regystro » Wed Feb 05, 2014 4:36 pm

Hi Pako.

Would it be possible to add HTTPS support into this plugin?

I'm a newbie in Python. did some research and found some info like http://www.piware.de/2011/01/creating-a ... in-python/
Someone also suggested using Request: viewtopic.php?f=2&t=5956&p=29139&hilit=https#p29134

I'd really love that because I'd like to trigger events remotely and securely from outside my home. I'd turn Air Conditioner on before I get home for instance :)

Thanks for such a great plugin!!

regystro
Posts: 2
Joined: Wed Feb 05, 2014 4:27 pm

Re: Any chance to get HTTPS / SSL?

Post by regystro » Thu Feb 06, 2014 5:16 pm

Hi again.

I just read Tornado documentation and managed to modify the plugin to require SSL connections.

You must add to the import section:

Code: Select all

import ssl
And then replace self.http_server = tornado.httpserver.HTTPServer(self) by:

Code: Select all

self.http_server = tornado.httpserver.HTTPServer(self,
	ssl_options=dict(
		certfile="server.crt",
		keyfile="server.key",
		cert_reqs=ssl.CERT_NONE))
Now you need to create your self-signed certificate. You'll need OpenSSL installed. I followed the 4 first steps of this guide: http://www.akadia.com/services/ssh_test ... icate.html
As stated in Step 2, make sure the Common Name matches the URL of your server.

Then copy server.crt and server.key to the main EventGhost folder (where Eventghost.exe resides). That's all.
If you don't want your browser to complain about untrusted certificate, install server.crt in Local computer > Trusted root certification authorities store

It would be nice to add the ability to choose wheter you want SSL or not in the plugin config tab, and also be able to select the cert files via a filepicker.
Also being able to start server in two different ports (SSL and No-SSL) would be great, so you could use https or http at will...

Pako, are you planning to improve this plugin or are you focused in the Webserver that comes with EventGhost?
I've been trying to add SSL to that one too, but as I said I'm a newbie in Python and I haven't succeeded so far. The plugin uses sockets and threads, and I'm a bit lost.
I guess you must use ssl_wrapper (http://docs.python.org/2/library/ssl.html) Don't know where in the code should I add ssl.wrap_socket function. Any help?

Best regards.

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Tornado (webserver with WebSocket)

Post by Sem;colon » Thu Feb 06, 2014 8:52 pm

leothlon wrote:is there realy no way of doing this?
Should i abandon my wishes to control and get data from xbmc with my tornado webserver completly?
i got tornado running on localhost:8085 and xbmc on localhost:8083,
Why cant i do ajax requests from tornado to xbmc, they are on the same computer why does it give same origin-policy-error?..

the url works when posted in a browser, but when fetched with ajax it doesn't work? why cant javascript emulate the browser request?

I've been looking for a solution over a week now and there just dont seem to be any way to get it to work?
Hello leothlon,

I'm not sure if it helps, but did you ever check out the webserver/Tornado function "send event to another webserver"?
This function can send a post request to any webserver and returns the answer.

leothlon
Experienced User
Posts: 59
Joined: Tue Dec 17, 2013 6:29 pm

Re: Tornado (webserver with WebSocket)

Post by leothlon » Fri Feb 07, 2014 7:21 am

But if i'm not mistaken that means your webserver needs to trigger an event in eg, then eg needs to execute an send event to another webserver, get the data from that webserver, then send it back to my page with websocket?... that's quite a chain... not to mention all the different combinations that would be needed based on if its tvshows, seasons, episodes, movies, music or other that i am requesting info about..

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Tornado (webserver with WebSocket)

Post by Sem;colon » Fri Feb 07, 2014 10:15 am

well, but you can trigger this function by using "ExecuteScript" from your ajax request to EG directly.

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Any chance to get HTTPS / SSL?

Post by Pako » Sat Feb 08, 2014 9:48 am

regystro wrote:Pako, are you planning to improve this plugin ...
Thank you for the interesting suggestion.
I'll deal with it and hope that I will find a solution.

Pako

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Any chance to get HTTPS / SSL?

Post by Pako » Wed Feb 12, 2014 6:26 pm

I just published an upgrade of the plugin (download in the opening post).
Plugin can now work with a secure protocol (https://).
regystro wrote:It would be nice to add the ability to choose wheter you want SSL or not in the plugin config tab, and also be able to select the cert files via a filepicker.
Tornado_SSL.png
If both fields contain a path to the valid file, it will be used https:// protocol.
Otherwise, it will used unsecured protocol http://.
regystro wrote:Also being able to start server in two different ports (SSL and No-SSL) would be great, so you could use https or http at will...
This would be very complicated and also unnecessary. If someone wants to provide for such a possibility, simply start the two servers. One with secure protocol and one with unsecure protocol.

Pako

kkl
Experienced User
Posts: 312
Joined: Wed May 04, 2011 9:32 pm

Re: Tornado (webserver with WebSocket)

Post by kkl » Fri Feb 14, 2014 1:35 am

Does this webserver support PHP, ASP, ASP.NET, or JSP? I didn't find any of those terms by searching this thread. I'm trying to figure out if it will support Ookla Speedtest Mini. Thanks.

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Tornado (webserver with WebSocket)

Post by Pako » Fri Feb 14, 2014 7:09 am

kkl wrote:Does this webserver support PHP, ASP, ASP.NET, or JSP? I didn't find any of those terms by searching this thread. I'm trying to figure out if it will support Ookla Speedtest Mini. Thanks.
No. Sorry to disappoint you.
Those two plugins (Webserver and Tornado) are a little different from the "normal" servers. You can not expect from them the same capabilities as from others (such as Apache).
It would certainly be possible to implement support for any of these languages.
But I personally do not intend to deal with it. I think it does not make sense. That would be completely out of frame for which they are intended.

Pako

kkl
Experienced User
Posts: 312
Joined: Wed May 04, 2011 9:32 pm

Re: Tornado (webserver with WebSocket)

Post by kkl » Fri Feb 14, 2014 4:06 pm

Pako wrote:No.
Thanks very much for the quick answer.

m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Tornado (webserver with WebSocket)

Post by m19brandon » Sun Mar 02, 2014 4:02 am

Enjoying this plugin greatly. I have a nice remote for my family room built using it with lots of jquery for css stuff. Works great on my two Androids and PCs but my main phone is an iPhone and iPhones like to disconnect the Wifi when locked. This is javascripting problem versus the plugin and was looking for some pointers. How can I correctly close the websocket connection when the screen locks. Right now I have refresh the page when I unlock the device to use the page again. T

Post Reply