The stock code use class Random to generate IV, the Random is pseudo random number generator. The IV maybe repeat, this will cause shadowsocks-libev closed the sockets with the error message 'invalid password or cipher'. Reference https://github.com/shadowsocks/shadowsocks-libev/issues/389 Solution is use class RNGCryptoServiceProvider to generate IV, of course it's lower performance, but a little bit.tags/2.5.7