Image copyright Getty Images Image caption Australia is caught between China, its biggest trading partner, and the US, its key strategic ally

In a recent Australian-made TV political thriller called Secret City, a cyber-attack paralyses the country's air traffic control system. Authorities immediately (and incorrectly) point the finger at Chinese hackers.

It's a storyline that's telling about Australia's attitude to Asia's pre-eminent power. On the one hand, China is the country's biggest trading partner, but it also poses a potential regional military threat that's drawing the attention of the US, Australia's closest defence ally.

China, for its part, appears keenly aware of Australia's apparent reluctance to embrace it fully. In recent months, a series of bilateral irritations have sent relations between the two countries plunging to their lowest point for nearly a decade.

China has rebuked Australia for opposing its military build-up in the South China Sea. Australia has blocked Chinese investment bids, ostensibly on national security grounds. A Chinese newspaper denounced Australia as a "paper cat that won't last". Even the countries' Olympians are fighting with one another.

Troubled relationship

When Australia's census website crashed this month, throwing the national survey into chaos, speculation about a Chinese cyber-attack ran rife. Peter Cai, a research fellow at the Lowy Institute for International Policy, says it is another illustration of the "troubled state of the relationship",

While the US has been Australia's main ally in the Asia-Pacific since World War Two, China has been central to the country's prosperity and its weathering of two global recessions.

But the balancing act which Australia has managed to perform has grown increasingly tricky of late. The US has switched its focus to the Asia-Pacific just as China asserts sovereignty over much of the South China Sea.

Last month, Beijing accused the US, Australia and Japan of "fanning the flames" of regional tensions, after the three issued a forthright statement urging China to respect an international court ruling rejecting those claims.

Image copyright Getty Images Image caption Australia and the US have strong military and strategic ties

Tensions have spilled out beyond the diplomatic world. During the Rio Olympics, thousands of Chinese took to social media to lambast Australian swimmer Mack Horton, who branded China's Sun Yang a "drug cheat" after the latter splashed him during a training session.

Power games

And then there's the issue of direct Chinese investment in Australia. Treasurer Scott Morrison has rebuffed two foreign investment bids - one from Chinese government-owned State Grid, the other from Hong Kong-based Cheung Kong Infrastructure - for a 50.4% stake in Ausgrid, which operates the electricity network in New South Wales state.

Mr Morrison insists domestic political considerations played no part in his decision, which followed his earlier rejection of a Chinese bid for the massive Kidman cattle station.

However, some have noted that following the federal election in July the Senate contains seven pro-protectionist crossbenchers. And although Australia signed a free trade agreement with China last year, there is growing popular antipathy to Chinese ownership of Australian agricultural land and real estate.

Image copyright Getty Images Image caption Australia's government has blocked the sale of the enormous Kidman cattle empire to Chinese buyers

Mr Morrison declined to spell out the security concerns behind the Ausgrid decision, which left some observers scratching their heads - not least because the two Chinese companies already own parts of the power grid in other states. As the news website Crikey observed, in relation to State Grid: "If it's a national security risk, as Morrison claims it is, then we're already screwed."

Toxic mindset

China's official Xinhua news agency warned in an English-language editorial that the Ausgrid knockback could lead to "a toxic mindset of China-phobia", adding: "To suggest that China would try to kidnap the country's electricity network for ulterior motives is absurd and almost comical."

Australian-Chinese relations have not yet plumbed the depths to which they fell in 2009, when Australian businessman Stern Hu was arrested in China on spying charges. But Mr Cai believes they could deteriorate further if, for instance, Australia joins the US in freedom of navigation exercises in the South China Sea.

Professor Richard Rigby, a veteran China-watcher at the Australian National University, notes that Australia has two China narratives: the economic one, which saw two-way trade increase ten-fold to A$100bn (£58bn) between 2002 and 2012, and the national security narrative.

"But we've not been good at all at bridging them," he said.