There is never a good time to yell at a referee and it is never appropriate. Not out of "the emotion of the moment". Not out of disagreement. Never.
The only appropriate conversation with a referee is a question from the player/coach, an answer from the official, and moving on. Everything else is inappropriate.
Referees are their own worst enemy as we try to be the "nice guy" and not penalize harassment. Call the penalty. Help yourself. Help the community.
The rule book gives us the tool to deal with harassment: Hockey Canada Rule 9.2
Assessing a penalty for referee harassment is not special. It is a penalty just like any other whether that is CFB 2 + GM, Head Contact 2 minutes, or 5+GM.
The referee does not need to "warn the benches" before assessing a penalty. Call a penalty; Make a statement that harassment will not be tolerated. If it is bad enough to warn then it is bad enough to penalize.
REDUCING RISK IDEA
-Statement about "its not your fault if you get harassed.
-Talk to captains not coaches; if you enforce the idea that you will never talk to coaches then they have one less excuse "that they are just calling you over". Captains also want to play...they are on the ice and that is their job...where as a coaches job is manage the game in the best way to win so coaches are more likely to prolong a conversation
-take the long route to avoid potential situation where someone can say something to you. This way, if they say something then it has to be really loud for everyone to hear. Hopefully, the idea of saying silly things is harder if they need to say it really hard.
-penalize harassment. Do not be a "nice guy".
Once they start yelling, they lose the privlege of talking to the referee. This helps set the standard "if you yell then I don't talk to you"
Linesman protect the referee. If the bench is giving her a hard time...tell them to stop. Get between players and the referee when it is obvious the player is being aggressive