The last time President Volodymyr Zelensky of Ukraine and China’s top leader, Xi Jinping, spoke, they celebrated 30 years of diplomatic ties, hailing their “deepening political mutual trust” and their people’s “profound friendship.”

That was in January of last year. Less than two months later, Russia, one of China’s closest partners, invaded Ukraine. Mr. Xi has not spoken since to Mr. Zelensky, despite the latter’s repeated requests. And the “sound and stable” relationship they touted seems like a distant memory.

The question of when and whether Mr. Xi will speak with Mr. Zelensky — which Western leaders have also urged him to do — reflects their countries’ uncertain state of relations amid Russia’s war in Ukraine. Before the war, trade and cultural exchanges had been growing. Now both sides are juggling goals that sometimes conflict.

Ukraine is wooing China for its potential to rein in Russian aggression. But it is keenly aware of Beijing’s demonstrated reluctance to do so, and of concerns that it could in fact arm Russia. Public opinion in Ukraine toward China is souring.

China, in turn, wants to maintain its professed neutrality in the conflict, and talks with Mr. Zelensky could bolster its desired image as a responsible global power. But it has also cast the war as a proxy battle over the future world order, with the United States on one side and itself and Russia on the other. Kyiv’s embrace of the West puts it on the wrong side of that divide.

There is also the reality that Ukraine, as a country under attack, does not hold the same economic appeal for China as before.

“Today’s Ukraine is still at war, China’s investments there have been bombed, and we don’t know what Ukraine will look like in the future,” said Zhu Feng, a professor of international relations at Nanjing University. “Is there still a China-Ukraine relationship?”

Before the invasion, the countries’ deepening ties were most apparent in their economic exchanges.

Between 2017 and 2021, exports from Ukraine to China quadrupled. By 2019, China was Ukraine’s largest trading partner and the top importer of its barley and iron ore, according to a report by the Council on Foreign Relations. Ukraine was also China’s largest corn supplier and its second-largest arms supplier. China’s first aircraft carrier, the Liaoning, was a discarded Soviet vessel bought from Ukraine that the Chinese Navy refurbished.

Ukraine’s then-prime minister declared 2019 the “year of China.” Chinese companies were tapped to build a new subway line in Kyiv. Ukraine’s free trade agreement with the European Union made it an attractive entry point for Chinese goods to flow into the lucrative market.

Cultural exchanges grew, too. A statue in Beijing’s largest park honors a Ukrainian poet. Mr. Zelensky’s wife, Olena Zelenska, delivered a virtual welcome speech at the 2021 Beijing International Film Festival. Many Ukrainians in China were students, according to Ukraine’s embassy.

Still, geopolitical tensions always loomed. China refrained from criticizing Russia after it annexed Crimea from Ukraine in 2014. Ukraine also faced pressure from the United States to distance itself from China, leading it in 2021 to scrap the $3.6 billion sale of a Ukrainian aerospace manufacturer to Chinese investors.

As Russian troops gathered at the Ukrainian border last year, Mr. Xi and President Vladimir V. Putin of Russia, meeting in Beijing, declared that their countries’ partnership had “no limits.”

After the war began, Beijing’s alignment became even clearer. It adopted many of the Kremlin’s talking points and disinformation, accusing NATO of instigating the conflict and refusing to call it an invasion. In the year since, Mr. Xi has met or spoken with Mr. Putin multiple times. On China’s heavily censored internet, popular videos celebrate Russian drone strikes, and nationalist influencers taunt Ukraine’s turn toward the West.

Even so, Ukraine has tried to win China’s support, recognizing it as perhaps the only country with influence over Russia. Mr. Zelensky has repeatedly invoked China’s stated respect for territorial integrity.

While many of Ukraine’s allies have lambasted what they perceive as China’s pro-Russian stance, Mr. Zelensky has been more cautious. He called Beijing’s recent position paper on the war, which many Western governments dismissed as lacking substance, “an important signal.” He has said that “I really want to believe” China will not arm Russia.

But frustration with China has grown in Ukraine, in the government and among ordinary people, said Yurii Poita, who leads the Asia section at the Kyiv-based New Geopolitics Research Network. An October poll by a Ukrainian research group found that unfavorable views of China had doubled since 2021, to 18 percent.

Mr. Xi’s visit to Moscow last month, where he and Mr. Putin reaffirmed their partnership, likely further tempered Kyiv’s expectations.

“Ukraine for a long period of time had huge illusions on China,” Mr. Poita said. “But now I believe their illusion is gradually diminishing, especially after this visit.”

At the same time, China has softened some of its rhetoric, especially as it seeks to improve relations with Europe. Chinese officials have recently played down the significance of the “no limits” declaration.

China may also see economic and strategic opportunity in Ukraine’s reconstruction, however the war ends, said Janka Oertel, director of the Asia Program at the European Council on Foreign Relations. “This could be an attractive way of then being a part of a postwar reordering,” she said. “The Chinese government would like to keep that economic relationship as open as possible.”

Still, China will go only so far.

China’s foreign minister has spoken with his Ukrainian counterpart, but the government has refused to say more about whether the top leaders would talk. Ursula von der Leyen, the head of the European Commission, said Mr. Xi told her last week that he was willing to speak to Mr. Zelensky “when conditions and time are right.”

Chinese experts argued that a call between the two would be of little use now, when neither Ukraine nor Russia appears inclined toward a cease-fire. American officials in fact have warned against cease-fire proposals for now, arguing that they would solidify Russian territorial gains.

“It’s not that we won’t make contact, but the question is what would they talk about?” said Wang Yiwei, the director of the Institute of International Affairs at Renmin University in Beijing. He added of Mr. Zelensky: “His hope for a call was that China would condemn Russia’s invasion and call for Russia to withdraw its troops. That’s not realistic.”

The uncertainty of the relationship trickles down to people like Anton Matusevych, a Ukrainian in Shanghai. Over eight years, Mr. Matusevych, 32, has built a life there, opening a therapy business and marrying a Chinese woman.

He knows that many Chinese support Russia but has tried to foster a community with those sympathetic to Ukraine, organizing cultural events and fund-raisers. “You cannot change the opinions of people,” he said. But “we can try to find connections and build the future relations.”

Still, his presence in China was increasingly conditional.

“We are trying to help, but at the same time we understand that this system is not helping Ukraine,” he said. If China armed Russia, he would leave: “There are lines which we cannot cross.”

Marc Santora and Zixu Wang contributed reporting and research.