The cast of "Glee" -- along with several producers -- knew Cory Monteith was battling a heroin addiction earlier this year and were the catalyst in his decision to go back to rehab, TMZ has learned.
Sources connected to the production tell us ... it was no secret Monteith was off his game back in March -- and it became clear he was relapsing, specifically with heroin.
We're told the cast and the producers became very concerned ... and knew they had to address the issue with Cory.
Sources say ... the group sat down with Cory and had an "open conversation" with the actor -- stressing how much they cared about him and wanted him to get help.
One source tells us Cory was very receptive -- "It wasn't met with resistance ... He was always so grateful and aware of how fortunate he was."
"The decision was to best help our friend. The needs of the show fell second to his well-being."
Cory voluntarily checked into rehab at the end of March for a 30 day stint ... but despite his efforts, he couldn't defeat his demons, and last week, he died from a lethal mixture of heroin and alcohol.
He was 31.