This is a pure CAN protocol question and it's not related to the MCU itself.
Example read this article: https://www.linkedin.com/pulse/can-buss-off-management-vikesh-kumar-mishra/
Watch this: https://www.youtube.com/watch?v=jxLxf1Mnu68
HOT connecting and disconnecting to the CAN bus during communication could result to CAN communication errors. So you need to recover from the bus off state as described in the reference manual:

For example, try this code for example to recover from the bus off state:
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.