How websocket of web3js stay connection?

How websocket of web3js stay connection?

When i sent a transaction with websocket. The connection always borken when the tx failed.

So how to hold the connection and just print an error message ?

maybe you can try to catch that exception