are rare, at least in my field (engineering).
I've done some consulting jobs, and I can straight-up state that they've never even come close to compensating sufficiently for time/hassle/energy expended. I still do them whenever I can, because I think that it's important for an engineering academic to keep one foot grounded in real life. However, I totally understand why my colleagues neglect it or straight-up avoid it like the plague.
When a company looks for a consultant, this is what they want. They want expertise RIGHT NOW. They want exactly what they need, and nothing else. They want to pay 100 dollars an hour. Actually, make that 90. If they can get away with 90, they'll propose 70. They'll haggle down to the last penny. Then, they insist that hours be accounted for down to the 15 minute increment and haggle over every increment in order to drive the price down.
I have no problem with this. These are businesses. They don't have the luxury of much state support and they operate really lean (at least in the US). So, I absolutely don't blame them. But the result is that my compensation gets nickel-and-dimed down to the point where it's barely even worth it. If it's happening formally through the university and the institution gets it's cut through overhead, I usually wind up doing 30 or 40 hours of work and my compensation amounts to a bag of groceries, and the paperwork alone makes it not worth it from a financial perspective.
The financials are so bad that, multiple times, I opted to consult and help a local company with a problem FOR FREE because that was a better deal for me, and at least I have the leverage to work the consulting around my teaching and research schedule. I still value it - I consider it an opportunity to get industrially relevant experience, and a bit of payback to the local economy and a form of charity. But it's a complete losing proposition from a pay perspective.
Maybe it's different in other fields.