def test_connection_limit(self):
        server = JsonRpcServer(echo_app)
        server.listen(('127.0.0.1', 0))
        addr = server.addresses[0]
        server.max_connections = 2
        clients = []
        exc = None
        try:
            for i in range(3):
                client = JsonRpcClient(timeout=2)
                client.connect(addr)
                client.call_method('echo')
                clients.append(client)
        except Exception as e:
            exc = e
        self.assertIsInstance(exc, TransportError)
        self.assertEqual(len(server.connections), server.max_connections)
        for client in clients:
            client.close()
        server.close()