This is probably answerable with a general reference (or a pair of such references), but I have not been able to find one.
Etymology Online does not cover the origin of "rubbing-elbows" as meaning to socialize or mingle in a crowd in either the section covering rub or elbow. Other top search hits just cover the meaning of the phrase in discussions of synonyms for socializing (hob-nob etc.), without going into the history and origins.
There is also the "elbow-handshake" (or less formally the "elbow-bump"), where literally rubbing elbows or forearms substitutes for a handshake greeting. Wikipedia traces this to a leprosy outbreak circa 1970 (in Hawaii, among peoples whose primary language may or may not have been English), but is very light on references. I first recall hearing of this handshake from watching a documentary about one of the 1990's Africa Ebola outbreaks, where it was presented as a de-facto greeting replacement that crossed cultures, creeds and nations.
My questions are what is the origin and time period of the phrase "rubbing elbows"? And does the practice of greeting with elbows or arms instead of hand have a more definite origin? And if so, is there any evidence that it was adopted with any conscious awareness of a literal acting out of a the common idiom "rubbing elbows"?