尝试与CometD/Bayeux服务器握手时获取未知的402客户端

2024-04-30 06:28:25 发布

您现在位置:Python中文网/ 问答频道 /正文

1-我试图订阅一个特定的频道,并从一个服务器获得一个长轮询,但我收到一个客户端未知错误402。以前有人面对过这个问题吗?代码中有什么遗漏吗

import asyncio
from aiocometd import Client
import aiocometd.exceptions as cometd_exc
from aiocometd import Client, ConnectionType

IP= "x.x.x.x"

#握手
异步def main():

    async with Client("http://"+IP+":8081/events/server/cometd",connection_timeout=60 , connection_types=ConnectionType.LONG_POLLING) as client:

            await client.subscribe("/events/rest/alarmEvent")

            async for message in client:
                print(message)
    try:
        message = await client.receive()
    except TransportTimeoutError:
        print("Connection is lost with the server. "
              "Couldn't reconnect in 60 seconds.")

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())


'Error code 402 //Unknown Client'
        

Tags: fromimportipclientloopasynciomessageasync