My case had nothing to do with a stored procedure, but the "unexpected end of stream" message instantly disappeared, when I killed an "htop"-Session running through another SSH-connection to a server I used for tunneling my DB connection. So also look out for these kinds of connection issues when you see that error message.