Few questions regarding your question.
What programming language do you use? Is it something C like? I used to do some programming with chess engines some 14 years ago (using winboard protocol, without much success though) and remember that it used anonymous pipes.
Does your bot work with GoGui - not via twogtp but directly?
Another GUI that supports GTP is Drago. Could be an option to check whether the bot works with that.