Websocket config

8 views
Skip to first unread message

Christopher Piggott

unread,
May 27, 2017, 8:00:21 PM5/27/17
to pytomation
I gave up for a while but I'm again trying to get websockets working.

My instance looks like this:

from pytomation.interfaces import PytoWebSocketServer

...
# disable standard web server
# web = HTTPServer()
...
# enable websocket server
ws
= PytoWebSocketServer()
...


You seem to have to have one or the other or they conflict.  The code and this mailing list suggest you can specify a port

ws = PytoWebSocketServer(port=8090)



but this doesn't seem to make any difference whatsoever.  The web server is still running on port 8080, and the websocket server still tries to come up and generates an 'address already in use' exception.

how is this supposed to actually work?  Normally, you would have one web server (not two) and it would be capable of serving normal pages plus handle upgrades to websocket on certain resource paths.  I'm not getting this idea of starting a whole second 'server' for websockets, unless the websocket server replaces the original http server AND provides its functions (feeding static web pages and handling non-websocket API requests).

All of this seems terribly broken to me, can somebody tell me if it's broken for others too?

--Chris

George Farris

unread,
May 28, 2017, 5:08:03 PM5/28/17
to pytom...@googlegroups.com
Hi Chris,

Here is my code in my instance.

from pytomation.common import config
from pytomation.interfaces import Serial, W800rf32, InsteonPLM, Wtdio, NamedPipe, PhillipsHue, \
                                StateInterface, Command, Arduino, PytoWebSocketServer, HTTP
from pytomation.devices import Motion, Door, Light, Location, InterfaceDevice, Room, \
                                Photocell, Generic, StateDevice, State, Attribute

###################### INTERFACE CONFIG #########################
#Web Server
websocket = PytoWebSocketServer()



Then in my pytomation/common/config.py file I have:

auth_enabled = 'Y'
admin_user = 'pyto'
admin_password = 'mation'
http_address = "0.0.0.0"
http_port = 8085
http_path = "./pytomation_web"


Restart and point your browser to http://localhost:8085

Or a real IP address if you are running on a different machine.


Cheers
George
--
You received this message because you are subscribed to the Google Groups "pytomation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytomation+...@googlegroups.com.
To post to this group, send email to pytom...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher Piggott

unread,
May 29, 2017, 9:19:29 AM5/29/17
to pytomation
Thanks, George.  I will try again.

One of the error messages I get is from gevent complaining about more than one service loop:

    NotImplementedError: gevent is only usable from a single thread

That comes from websocket_server's run() ... so I'm thinking now that somebody else is trying to start a gevent loop somewhere, I just haven't found it yet.

(I've tried the 'monkey patching' but that didn't help - and I'm not convinced that it should have).

Working on it...
Reply all
Reply to author
Forward
0 new messages