Websocket disconnect

I tried to connect to infura’s websocket, but my application disconnected in the fiftieth second when both parties had no messages (not disconnected when there is a message), as shown in the figure below, what should I do, I need help(my test url: EasySwoole-WebSocket在线测试工具)

Hi @Jun_Jack, welcome to the Infura community! Can you please share your code with us so we can try to help you debug this?

Hi @Leiya_Kenney , thanks for your help,I think this has nothing to do with my code, because I got the same test results on both wscat and http://www.easyswoole.com/wstool.html, They are all disconnected in the fiftieth second of inactivity(i use wscat -c wss://mainnet.infura.io)

When I try to use your test URL, I get the following debug message:

It sounds like perhaps a close frame is not being sent; have you tried calling ws.close() before the page unload to see if it makes a difference?

I am connected to the websocket address provided by infura, have you connected youself address ?

Even if i use wscat, I still receive the error code of 1006,but reason property is empty, so, What is the reason of the error?

Hmm. When I have connected via the infura websocket address, I don’t run into this same error. Let us look into it and we’ll let you know when we’ve found something!

Hi @Jun_Jack do you get this same behavior using eth_subscribe with a newHeads subscription type?

No, the channel will be closed only when there are no messages within 50 seconds

Thanks, our recommendation would be to either implement reconnect logic in the event no messages are delivered based on your parameters or have a newHeads sub type on the connection as well. Both of these should manage the issue you’re experiencing.