STS-125 Mission Specialist Mike Massimino works with the Hubble Space Telescope in the cargo bay of the Earth-orbiting space shuttle Atlantis on May `15, 2009.

-

In 1969, when Mike Massimino was seven years old, he dreamt of being an astronaut just like Neil Armstrong, who had just made his historic moon landing. Before the age of 33, Massimino got rejected by NASA three times until he finally reached his goal and learned an important lesson on patience and persistence.

"The most important thing is to never give up. As long as you keep trying, there is always a chance," Massimino tells CNBC Make It. Massimino went on to travel on two space missions, of which the second helped him become the first person to ever tweet from space on May 12, 2009.

Massimino, 55, is the author of The New York Times bestseller "Spaceman," and serves as the senior advisor at the Intrepid Museum while teaching at his alma mater Columbia University.

It was right after graduating from Columbia in 1984 that Massimino wrote a letter to a top NASA administrator out of the blue that would later lead to his first job at NASA, he recalls in "Spaceman."

Although that administrator didn't reply to Massimino's letter, his executive officer Franky Coy did. Soon, Massimino and Coy were on the phone, discussing different jobs at NASA and establishing a connection that would eventually prove valuable. As a graduate student at MIT, Massimino got an administrative engineering job at NASA's headquarters.

When working toward his Ph.D. at MIT to gain a competitive edge over other aspiring astronauts, Massimino made it into the top 10 percent of NASA's astronaut program applicants. To his dismay, he got rejected for having bad eyesight. One eye procedure later, Massimino was determined to apply again.

"Surely NASA would want me now. All I had to do was go back to MIT and do the impossible thing had nearly killed me: pass my qualifying exam," Massimino wrote, referring to completing his Ph.D.

When Massimino applied to the astronaut program a second time, he got rejected yet again. This time, for listing references who didn't know him well and provided less-than-impressive recommendations.

"I did that with a couple of the recommendations: I picked people I thought were important instead of people who knew me. That was a mistake," Massimino wrote.

At a time when NASA was getting upwards of 5,000 applicants per astronaut program class, Massimino applied a third time and got through to the final round, an in-person interview. And for a third time, he got rejected. This time, because of a medical disqualification due to of his eyesight.

"I was crushed. It'd been 10 years. Ten years of my life I'd been working toward this goal. I didn't know whether to feel angry or sad or frustrated or what," Massimino wrote.

Instead of remaining disheartened, he got in touch with the program selection committee, who told him he could still try applying if he could correct his eyesight.

"After everything I'd invested, for me to walk away the door had to be closed and closed forever," Massimino said. "As long as it was open, even just a crack, I knew that I couldn't bring myself to stop trying. I'd made it too far and come too close to give up, and I had nothing left to lose."

In the meantime, after getting his Ph.D., Massimino worked as a professor at Rice University and Georgia Institute of Technology. In 1995, he applied to NASA's astronaut program a fourth time and went through several months of vision training, which helped him pass the same eye exam he previously failed.

In May of 1996, Massimino was selected to be a NASA astronaut candidate. After years of training, he flew with a crew to space in 2002 and 2009 as part of the final two trips to service the Hubble Space Telescope. He spent exactly 571 hours and 47 minutes in space.

To this day, Massimino says he is still actually afraid of heights, but he holds onto this lesson: "It's important to have dreams. Sometimes they come true like it did with my astronaut opportunities and sometimes you get disappointment."

"But I think the most important thing is to have a dream and to pursue it. Sometimes it will work out and sometimes it won't, but the important thing is to try," he says.