ESP8266 Relay with 2N2222 transistors
If everything is ok until you apply the AC voltage on the relay contact, it means it is an electromagnetic compatibility problem.
Use a snubber circuit (RC snubber for example) at the contact of the relay to avoid elecromagnetic interference.