How to use the autobahn.twisted.websocket.connectWS function in autobahn

To help you get started, we’ve selected a few autobahn 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 crossbario / autobahn-testsuite / autobahntestsuite / autobahntestsuite / broadcast.py View on Github external
def startClient(wsuri, debug = False):
   factory = BroadcastClientFactory(wsuri, debug)
   connectWS(factory)
   return True
github shaunduncan / helga / helga / bin / helga.py View on Github external
def run():
    """
    Run the helga process
    """
    backend = _get_backend(settings.SERVER.get('TYPE', 'irc'))
    smokesignal.emit('started')

    factory = backend.Factory()

    if settings.SERVER.get('TYPE', False) == 'slack':
        connectWS(factory=factory)
    elif settings.SERVER.get('SSL', False):
        reactor.connectSSL(settings.SERVER['HOST'],
                           settings.SERVER['PORT'],
                           factory,
                           ssl.ClientContextFactory())
    else:
        reactor.connectTCP(settings.SERVER['HOST'],
                           settings.SERVER['PORT'],
                           factory)
    reactor.run()
github clp-research / deep_disfluency / deep_disfluency / feature_extraction / get_ibm_asr_results.py View on Github external
# create a WS server factory with our protocol
    url = "wss://" + hostname + "/speech-to-text/api/v1/recognize?model=" + args.model
    summary = {}
    factory = WSInterfaceFactory(q, summary, args.dirOutput, args.contentType, args.model, url, headers, debug=False)
    factory.protocol = WSInterfaceProtocol

    for i in range(min(int(args.threads),q.qsize())):

        factory.prepareUtterance()

        # SSL client context: default
        if factory.isSecure:
            contextFactory = ssl.ClientContextFactory()
        else:
            contextFactory = None
        connectWS(factory, contextFactory)

    reactor.run()

    # dump the hypotheses to the output file
    fileHypotheses = args.dirOutput + "/hypotheses2.txt"
    f = open(fileHypotheses,"w")
    counter = 1
    successful = 0 
    emptyHypotheses = 0
    for key, value in (sorted(summary.items())):
        if value['status']['code'] == 1000:
            print key, ": ", value['status']['code'], " ", value['hypothesis'].encode('utf-8')
            successful += 1
            if value['hypothesis'][0] == "":
                emptyHypotheses += 1
        else:
github ebu / ebu-tt-live-toolkit / ebu_tt_live / twisted / websocket.py View on Github external
def connect(self):
        log.info('Connecting to {}'.format(self.url))
        connectWS(self)
github hungtraan / FacebookBot / Speech / speech_py.py View on Github external
print("WebSocket connection closed: {0}".format(reason), "code: ", code, "clean: ", wasClean, "reason: ", reason)
      self.summary[self.uttNumber]['status']['code'] = code
      self.summary[self.uttNumber]['status']['reason'] = reason
      
      # create a new WebSocket connection if there are still utterances in the queue that need to be processed
      self.queue.task_done()

      if self.factory.prepareUtterance() == False:
         return

      # SSL client context: default
      if self.factory.isSecure:
         contextFactory = ssl.ClientContextFactory()
      else:
         contextFactory = None
      connectWS(self.factory, contextFactory)
github sammchardy / python-binance / binance / websockets.py View on Github external
def _start_socket(self, path, callback, prefix='ws/'):
        if path in self._conns:
            return False

        factory_url = self.STREAM_URL + prefix + path
        factory = BinanceClientFactory(factory_url)
        factory.protocol = BinanceClientProtocol
        factory.callback = callback
        factory.reconnect = True
        context_factory = ssl.ClientContextFactory()

        self._conns[path] = connectWS(factory, context_factory)
        return path
github datasift / datasift-python / datasift / client.py View on Github external
def _stream(self):  # pragma: no cover
        """Runs in a sub-process to perform stream consumption"""
        self.factory.protocol = LiveStream
        self.factory.datasift = {
            'on_open': self._on_open,
            'on_close': self._on_close,
            'on_message': self._on_message,
            'send_message': None
        }
        if self.config.ssl:
            from twisted.internet import ssl
            options = ssl.optionsForClientTLS(hostname=WEBSOCKET_HOST)
            connectWS(self.factory, options)
        else:
            connectWS(self.factory)
        reactor.run()
github vnpy / vnpy / vnpy / api / binance / websockets.py View on Github external
def _start_socket(self, path, callback, prefix='ws/'):
        if path in self._conns:
            return False

        factory_url = self.STREAM_URL + prefix + path
        factory = BinanceClientFactory(factory_url)
        factory.protocol = BinanceClientProtocol
        factory.callback = callback
        factory.reconnect = True
        context_factory = ssl.ClientContextFactory()

        self._conns[path] = connectWS(factory, context_factory)
        return path
github monolithworks / trueseeing / cli / trueseeing / api / client_twisted.py View on Github external
def hello(host, port, target):
    from twisted.internet import reactor

    if KEY is not None:
        key = {'X-Trueseeing2-Key':KEY}
    else:
        key = None
    with open(target, 'rb') as f:
        factory = WebSocketClientFactory(u"wss://%s:%d/analyze" % (host, port), headers=key)
        factory.isSecure = True
        factory.protocol = TrueseeingClientProtocol.withFile(f)
        connectWS(factory)
        reactor.run()
github Coinigy / api / coinigy_ws.py View on Github external
# ui
    controller = Controller()
    stdio.StandardIO(controller)

    factory = CoinigyWSClientFactory(_END_POINT, controller, config_dict)
    factory.protocol = CoinigyWSClient

    if factory.isSecure:
        contextFactory = ssl.ClientContextFactory()
    else:
        contextFactory = None

    print("Has SSL context factory: {}".format(contextFactory))

    connectWS(factory, contextFactory)
    reactor.run()