How to use the websockify.websocketproxy.WebSocketProxy function in websockify

To help you get started, we’ve selected a few websockify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mbsim-env / mbsim / misc / BuildService / scripts / mbsimwebapp_service.py View on Github external
websockify.websockifyserver.CompatibleWebSocket.__init__(self)
    self.lastPing = time.time()                                                                   
    threading.Thread(target=self.checkKill).start()   
  def checkKill(self):                      
    while True:                                 
      time.sleep(5)                             
      if time.time()-self.lastPing>30:            
        websockify.logging.getLogger(websockify.WebSocketProxy.log_prefix).info('Client seems to be dead. No ping since 30sec. Killing now.')
        os._exit(0)        
  def handle_pong(self, data):                                                                        
    self.lastPing = time.time()                 

class MyPRH(websockify.websocketproxy.ProxyRequestHandler):
  SocketClass=MyWebSocket

server = websockify.websocketproxy.WebSocketProxy(
  RequestHandlerClass=MyPRH,
  listen_host='localhost',
  listen_port=10080,
  heartbeat=10,
  token_plugin=MBSimWebappToken(None),
  auth_plugin=MBSimWebappAuth(None),
)
server.start_server()
github novnc / websockify / websockify / websocketproxy.py View on Github external
auth_plugin_cls = getattr(sys.modules[auth_plugin_module], auth_plugin_cls)

        opts.auth_plugin = auth_plugin_cls(opts.auth_source)

    del opts.auth_source

    # Create and start the WebSockets proxy
    libserver = opts.libserver
    del opts.libserver
    if libserver:
        # Use standard Python SocketServer framework
        server = LibProxyServer(**opts.__dict__)
        server.serve_forever()
    else:
        # Use internal service framework
        server = WebSocketProxy(**opts.__dict__)
        server.start_server()
github novnc / websockify / websockify / websocketproxy.py View on Github external
def select_ssl_version(version):
    """Returns SSL options for the most secure TSL version available on this
    Python version"""
    if version in SSL_OPTIONS:
        return SSL_OPTIONS[version]
    else:
        # It so happens that version names sorted lexicographically form a list
        # from the least to the most secure
        keys = list(SSL_OPTIONS.keys())
        keys.sort() 
        fallback = keys[-1]
        logger = logging.getLogger(WebSocketProxy.log_prefix)
        logger.warn("TLS version %s unsupported. Falling back to %s",
                    version, fallback)

        return SSL_OPTIONS[fallback]