Websocket provider always disconnect

Hi
i use Moralis wss endpoint for BSC as below:

MORALIS_NODE_WSS i copy from my dashboard BSC endpoint.

provider = new ethers.providers.WebSocketProvider(MORALIS_NODE_WSS);
provider.on(ā€œpendingā€, async (txHash) => {
// do some stuff hereā€¦
}

it can work for 10 seconds then the websocket will closed and i do the retry but can
not connect anymore. you need to wait for maybe 20 seconds then it will work again for another 10 - 20 seconds

is this normal ? how can i solve this ?

I would expect it to be able to reconnect fast. Do you get any errors? Maybe you can also use reconnect options when first connection is made.

i do retry to connect. below is the current log.
Watching the txpool for events for token .
Watching the txpool for events for token
WebSocket Closed. Reconnectingā€¦
Watching the txpool for events for token
WebSocket Closed. Reconnectingā€¦
Error. Attemptiing to Reconnectā€¦
WebSocket Closed. Reconnectingā€¦
Error. Attemptiing to Reconnectā€¦
WebSocket Closed. Reconnectingā€¦

provider._websocket.on(ā€œerrorā€, () => {
console.log(ā€œError. Attemptiing to Reconnectā€¦ā€);
clearInterval(keepAliveInterval);
clearTimeout(pingTimeout);
startMonitorTarget();
});

i print the error.

Error Error: Unexpected server response: 429

That error code looks like a rate limit error.
I donā€™t know how to fix. Maybe you can set the interval for ping requests.

You get that error code 429 when you try to make the first reconnect?

almost, i adjust little bit and try. but it disconnect websocket quite often through. can not work reliably.

Maybe you can try another node provider. After you get the list of pending transactions you will also have to get the transaction info that will require another request per transaction hash.