Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Tornado (webserver with WebSocket)

Questions and comments specific to a particular plugin should go here.
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 »

I do not know if there are any browsers fully support HTML5, also on the platform iPhone / iPod / iPad and the Windows phone platform.
Please, is there anyone among us who has the opportunity to try it?

Thanks, Pako
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

On iPhone it is supported perfectly out of the box in Safari and UC Browser+


Best regards, Walter

PS In the next post is the simple test html page I made that is using websockets with your Tornado plugin and it is working just as perfect in the iPhone with Safari, UC Browser+ as well as under Windows (Vista) in Chrome, Firefox and Opera.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

Hello,

I decided to try to create a very simple sample of an html page just to understand and try out the websocket functionality with your Tornado plugin. It is working fine

I just copied the file to the EventGhost www-musicbee folder where you have the index.html and related.

One problem I at least have. Everytime I edit a html-files, the changes are not affective unless I restart EG completely. I tried to stop/start the plugin but it doesn't help. It seems that the Tornado server is caching existing pages somehow.

Would need a kind of page re-load action or so...

Best regards, Walter
simple.zip
(832 Bytes) Downloaded 163 times
PS now also tested successfully with Blackhawk, Torch Browser under Windows.
Works also fine with Chrome under Android
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 »

Hi Walter,
Thank you for your detailed feedback.
So i-family is fine, so there is a need to test Windows phone platform, if I understand it well.

Best regards,
Pako
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

Well, your MusicBee page also loaded fine but I did not control the MusicBee itself but I can see MB events in EventGhost when I tap the web buttons on the iPhone. It connects without problems.

So I would say yes, if you make web pages with websocket features as provided, it works fine

My best regards, Walter
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

Dear Pako,

Now I have fully migrated my home automation system to use your Tornado plugin including the websocket support.
It is working very well.

The old solution based on webserver and websocket suite plugins has done a great job so far but now it is time to move forward!

Thanks,
Walter
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 »

krambriw wrote:Now I have fully migrated my home automation system to use your Tornado plugin including the websocket support.
It is working very well.
Dear Walter,
I'm very, very pleased.
I assumed (already during the development Tornado plugin), that in projects, using the Tornado,
some of the options of the original Webserver plugin will be unused.
However, despite the fact I made ÔÇïÔÇïa new plugin as compatible as possible.
It was for this reason in order the transition (from Tornado plugin to Webserver plugin) was as simple as possible.
BTW, which new "Websocket actions" you use the most?
Do you have any suggestions for improvements?
Do you have any suggestions for better wording of the text?

Thanks, Pako
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

Dear Pako,
It is a bit early to say in details yet, I have to use if for a while and discover more possibilities.
Currently I am using mostly 'BroadcastMessage'

Best regards, Walter

PS if you find a solution so that it is possible to edit & change a html page without restarting EG would of course be very much wished for
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 »

krambriw wrote:PS if you find a solution so that it is possible to edit & change a html page without restarting EG would of course be very much wished for
Dear Walter,
I am convinced that it is not necessary to restart EventGhost.
That should be enough to empty your browser cache.
But in my experience EventGhost restart is often faster.

Pako
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

Dear Pako,

This morning I discovered the Tornado plugin with an error as in the log below. The CPU load was very high, when stopping (disabling) the Tornado plugin, it was down to normal low again. Enabling it, the CPU load was very high again.
It was a normal BroadcastMessage action request that was causing this.
I had to restart EG to cure the problem...

Best regards, Walter
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\__init__.py", line 1265, in __call__
23:29:01 return self.plugin.BroadcastMessage(message)
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\__init__.py", line 2916, in BroadcastMessage
23:29:01 client.write_message(message)
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\__init__.py", line 849, in write_message
23:29:01 self.ws_connection.write_message(message, binary=binary)
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\lib\tornado\websocket.py", line 593, in write_message
23:29:01 self._write_frame(True, opcode, message)
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\lib\tornado\websocket.py", line 582, in _write_frame
23:29:01 self.stream.write(frame)
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\lib\tornado\iostream.py", line 220, in write
23:29:01 self._handle_write()
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\lib\tornado\iostream.py", line 551, in _handle_write
23:29:01 _merge_prefix(self._write_buffer, num_bytes)
23:29:01 File "C:\Program\EventGhost\plugins\Tornado\lib\tornado\iostream.py", line 1003, in _merge_prefix
23:29:01 chunk = deque.popleft()
23:29:01 IndexError: pop from an empty deque
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 »

Dear Walter,
At this point, I do not know what to do.
But perhaps the cause could be some unusual format of the message.
You have the opportunity to find out what was the content of the message, when it happened?

Best regards,
Pako
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

Hello Pako,

In the meantime I have changed the code in iostream.py from line 1002 to the below. I will run for a while and see if it comes back and what can be debugged...

Code: Select all

    while deque and remaining > 0:
        try:
            chunk = deque.popleft()
            if len(chunk) > remaining:
                deque.appendleft(chunk[remaining:])
                chunk = chunk[:remaining]
            prefix.append(chunk)
            remaining -= len(chunk)
        except:
            app_log.error(str(prefix),
                                      exc_info=True)
            app_log.error(str(deque),
                                      exc_info=True)
            app_log.error(str(remaining),
                                      exc_info=True)
Last edited by krambriw on Mon Jan 20, 2014 1:02 pm, edited 1 time in total.
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 »

Hi Walter !
krambriw wrote: INstead of 'pass' I tried to insert a print statement but I did not manage to get it work
I've discovered during development that I can not use print inside the Tornado code.
But eg.Print() or eg.PrintError(), it worked ...

Pako
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Tornado (webserver with WebSocket)

Post by krambriw »

ok, thanks I have changed a bit, see above in the code
leothlon
Experienced User
Posts: 59
Joined: Tue Dec 17, 2013 6:29 pm

Re: Tornado (webserver with WebSocket)

Post by leothlon »

is it possible to get eventghost var iable in an javascript for the site?
in the html file you just do {{eg.globals.variablename}} right? but how can i use the eg variable in the javascript?

couse for some reason xbmc dont alow cross domain requests, so i cant have my eg webpage fetch data from xbmc library, so my thought would be to have eg xbmc plugin fetch the data every x hours and save it to a variabe i then call in my javascript...
or if anyone know a way to post and url and fetch the response cross site that would work to :P
Post Reply