Example #1
0
 def testSockOpts(self):
   ws = websocket.create_connection('ws://echo.websocket.org')
   self.assertNotEquals(
       ws.sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR), 0)
   ws = websocket.create_connection(
       'ws://echo.websocket.org',
       sockopt=[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)])
   self.assertNotEquals(
       ws.sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR), 0)
   self.assertNotEquals(
       ws.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY), 0)
Example #2
0
  def testSockOpts(self):
    httpd = BaseHTTPServer.HTTPServer(('', 0), _FakeWebSocketHandler)
    threading.Thread(target=httpd.handle_request).start()
    ws_url = 'ws://127.0.0.1:%d' % httpd.server_port
    ws = websocket.create_connection(ws_url)
    self.assertNotEquals(
        ws.sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR), 0)

    threading.Thread(target=httpd.handle_request).start()
    ws = websocket.create_connection(
        ws_url,
        sockopt=[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)])
    self.assertNotEquals(
        ws.sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR), 0)
    self.assertNotEquals(
        ws.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY), 0)
Example #3
0
    def testSockOpts(self):
        httpd = BaseHTTPServer.HTTPServer(('', 0), _FakeWebSocketHandler)
        threading.Thread(target=httpd.handle_request).start()
        ws_url = 'ws://127.0.0.1:%d' % httpd.server_port
        ws = websocket.create_connection(ws_url)
        self.assertNotEquals(
            ws.sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR), 0)

        threading.Thread(target=httpd.handle_request).start()
        ws = websocket.create_connection(ws_url,
                                         sockopt=[(socket.IPPROTO_TCP,
                                                   socket.TCP_NODELAY, 1)])
        self.assertNotEquals(
            ws.sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR), 0)
        self.assertNotEquals(
            ws.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY), 0)
Example #4
0
  def _Connect(self, timeout=10):
    assert not self._socket
    try:
      self._socket = websocket.create_connection(self.debugger_url,
          timeout=timeout)
    except (websocket.WebSocketException):
      if self._browser_backend.IsBrowserRunning():
        raise exceptions.TabCrashException(sys.exc_info()[1])
      else:
        raise exceptions.BrowserGoneException()

    self._cur_socket_timeout = 0
    self._next_request_id = 0
Example #5
0
    def _Connect(self):
        if self._socket:
            return
        try:
            self._socket = websocket.create_connection(self._debugger_url)
        except (websocket.WebSocketException):
            if self._browser_backend.IsBrowserRunning():
                raise exceptions.TabCrashException(sys.exc_info()[1])
            else:
                raise exceptions.BrowserGoneException()

        self._cur_socket_timeout = 0
        self._next_request_id = 0
Example #6
0
    def _Connect(self, timeout=10):
        assert not self._socket
        try:
            self._socket = websocket.create_connection(self.debugger_url, timeout=timeout)
        except (websocket.WebSocketException):
            err_msg = sys.exc_info()[1]
            if not self._browser_backend.IsBrowserRunning():
                raise exceptions.BrowserGoneException(err_msg)
            elif not self._browser_backend.HasBrowserFinishedLaunching():
                raise exceptions.BrowserConnectionGoneException(err_msg)
            else:
                raise exceptions.TabCrashException(err_msg)

        self._cur_socket_timeout = 0
        self._next_request_id = 0
Example #7
0
    def _Connect(self, timeout=10):
        assert not self._socket
        logging.debug('InspectorBackend._Connect() to %s' % self.debugger_url)
        try:
            self._socket = websocket.create_connection(self.debugger_url,
                                                       timeout=timeout)
        except (websocket.WebSocketException, util.TimeoutException):
            err_msg = sys.exc_info()[1]
            if not self._browser_backend.IsBrowserRunning():
                raise exceptions.BrowserGoneException(err_msg)
            elif not self._browser_backend.HasBrowserFinishedLaunching():
                raise exceptions.BrowserConnectionGoneException(err_msg)
            else:
                raise exceptions.TabCrashException(err_msg)

        self._cur_socket_timeout = 0
        self._next_request_id = 0
 def __init__(self, devtools_port):
   debugger_url = 'ws://localhost:%i/devtools/browser' % devtools_port
   self._socket = websocket.create_connection(debugger_url)
   self._next_request_id = 0
   self._cur_socket_timeout = 0
 def __init__(self, devtools_port):
     debugger_url = 'ws://localhost:%i/devtools/browser' % devtools_port
     self._socket = websocket.create_connection(debugger_url)
     self._next_request_id = 0
     self._cur_socket_timeout = 0
 def Connect(self, url, timeout=10):
   assert not self._socket
   self._socket = websocket.create_connection(url, timeout=timeout)
   self._cur_socket_timeout = 0
   self._next_request_id = 0