Websocket connection disconnects after few minutes

Hey there! Thanks for the reply!

I see that i didn’t specify more details, my bad.
I do have a successful connection to PubSub’s “channel-points-channel-v1”

with the response:

{‘type’: ‘RESPONSE’, ‘error’: ’ ', ‘nonce’: ‘123456789p’}

To answer your question about PING:
Yes i do get a PONG as a response.

Here is the basic code:

url = “wss://pubsub-edge.twitch.tv”

loop = asyncio.get_event_loop()

connection = websockets.connect(url, ping_interval=None)

async def keepAlive():
async with connection as socket:
while(True):

        ping = json.dumps({
            "type": "PING" })

        await socket.send(ping)
        res = await socket.recv()
        print(res)
        await asyncio.sleep(100 + random.randrange(1,50))

async def listen():
async with connection as socket:
data = json.dumps({
“type”:“LISTEN”,
“nonce”: “123456789p”,
“data”: {
“topics”: [“channel-points-channel-v1.” + channel_id],
“auth_token”: access_token,
}
})
await socket.send(data)

    resp = await socket.recv()

    dec_resp = json.loads(resp)

    print(dec_resp)
    
    # while(loop.is_running):
        
    async for msg in socket:
        pass

       # Some logic...

loop.create_task(keepAlive())

loop.run_until_complete(listen())

Sorry for my late response.