In the Treaty of Nanking ( 1842 ) China was compelled to open five of its ports to foreign economic and political penetration , and even to compensate the opium smugglers for their losses .
China never opened any ports to foreign countries or goods .