Space is not to be trifled with," the ailing Soviet cosmonaut reportedly said shortly before dawn on his precipitous return to earth last week after nearly six months in orbit.

According to Radio Moscow, the cosmonaut, 36-year-old Alexander Laveikin, began registering abnormal heart rhythms on his remote electrocardiogram two weeks ago. The Soviets launched a rescue mission, sending a capsule with three men aboard, one to replace Laveikin in the two-person Mir space station, the others to escort him back to Moscow.

While cardiovascular problems were the official reason for Laveikin's early homecoming, some American space experts say there might have been additional difficulties from the the stress of prolonged weightlessness and confinement.

"Even highly trained, highly motivated people have a limit," says Dr. Patricia Santy, a psychiatrist and flight surgeon with the National Aeronautics and Space Administration at the Johnson Space Center in Houston. She sets that limit at three or four weeks. "After that, if you have interpersonal conflict in that confined micro-society, things can get out of hand."

The longest American space flight -- the last Skylab mission -- was 84 days in 1973-74. The Soviet Union's Salyut project involves far longer missions for its two- and three-person crews; the record to date is 237 days set in 1984. Laveikin and his mate had been in orbit since Feb. 5 -- for 176 days -- and were working on breaking the record.

A major goal for NASA is to place a manned space station in orbit by the mid-1990s, in which crews would be aloft for six months at a time. The space agency also is looking into the possibility of a manned expedition to Mars that would involve three years in space.

For decades, scientists have been studying the psychological effects of living for long periods in cramped quarters, with no one around except other crew members. Research on groups living in nuclear submarines, oceanographic vessels, Antarctic research stations and Alaskan oil-pipeline construction camps has documented the unique form of cabin fever that occurs when the cabin is not only small but isolated.

"So far, there has been one murder" in these close quarters -- in this case, an Antarctic research station, according to Dr. B.J. Bluth, a sociologist involved in architectural design for NASA's space station program. Navy crewmen "wintering over" in Antarctic stations, she adds, have shown "an increase of 40 percent in stress-related symptoms of anxiety, depression, insomnia and hostility."

During one especially strained two-year ocean voyage, Bluth says, bickering between sailors and scientists on a British vessel culminated when the crew "tossed overboard a large part of the specimens collected because of a dispute about the use of a freezer."

A favorite game on nuclear submarines is "pinging." According to Dr. Nick A. Kanas, associate professor of psychiatry at the University of California at San Francisco and acting chief of psychiatry at the Veterans Administration Medical Center, "one sailor teases another about some tender subject and wins the game if he can elicit an angry reaction."

In space, where the stress of isolation is compounded by the stress of prolonged weightlessness, problems can go beyond hostility and anxiety. Astronauts usually complain of various psychosomatic symptoms, including sleep disturbance, time disorientation and headaches.

Sleeping in space is no easy task. Some astronauts like to float in the air, while others tie themselves to beds and wrap themselves in sleeping bags. During the Gemini VII mission, one astronaut was monitored by EEG transmitter for 55 hours, during which time he averaged only 5.3 hours of sleep a night.

Time compression in space has led to fights between astronauts and ground crews, with the men in space feeling rushed and the men on earth growing impatient. This kind of disagreement has led to out-and-out fights between the two. Bluth says she has heard that on one of the Soviet Union's Salyut missions, which involved 185 days in space, irate cosmonauts turned off their radio for two days.Psychological hazards of space flight can become physical hazards.One of Laveikin's predecessors, while on an earlier Salyut mission, kept a diary of his own psychosomatic symptoms. "In the actual flight, I was afraid most of all of an appendicitis attack," he wrote about his 175-day flight. He also feared a space toothache. "Once in flight I dreamed I had a toothache," he wrote. "I awoke almost instantly, feeling, yes, my tooth really did hurt." The pain was gone by morning.

Heartbeat abnormalities, such as the one that grounded Laveikin, are a known result of stress, Santy points out. "People on earth under emotional stress tend to have arrhythmias," she says.

Stress can affect an individual's resilience, too. According to Santy, "most of the studies on living in closed quarters show a rise in all the hormones that mediate stress," such as cortisol and epinephrine.

In addition, says Santy, "zero gravity itself might take away an individual's physiological capabilities to respond to stress."

Weightlessness itself is not really a problem, says NASA's Bluth. In fact, astronauts tend to enjoy floating around. But she says they complain about the exercises they must do for two hours each day on an ex- ercise bicycle and treadmill to avoid the bone loss and muscle atrophy that can result from prolonged weightlessness.

The lack of gravity, she says, also means the astronaut's perspiration has nowhere to go and simply hovers around him "in big wet globs" as he performs his unvarying routine.

Physical changes may even aggravate crew relations -- sometimes in surprising ways. According to an article in Discover magazine, in the absence of gravity, body fluids tend to float to the head, puffing out the face and making features and, most important, facial expressions, difficult to discern and interpret.

Yet most space flight physicians believe it is the isolation that is the main source of emotional stress. "Weightlessness may not be psychologically as significant as it is physiologically," Kanas says. "The hooker, psychologically, is simply the idea of being confined."

Sometimes the stress of confinement impairs judgment -- especially when the urge to get out of the space capsule becomes overwhelming. "One Salyut 6 cosmonaut became so enraptured with his view from an open air lock," says Kanas, "that he made an impulsive, unauthorized extravehicular excursion and forgot to attach his safety line." He was saved by a quick-thinking colleague, who grabbed him and hauled him inside.

As men and women head out to space for longer periods, NASA engineers are trying to develop crafts thought to be more "habitable." One important feature will be extra windows, since astronauts have reported that their favorite pasttime in flight was gazing out the window at the cosmic scenery. As Santy says, a spaceship without windows "is like a house at the beach without a view of the ocean."