It's not clear from your code snippet when you request market data, etc. You should do that after receiving the nextValidId() event which signals successful connection.
If you have any unhandled exceptions, all subscribed data streams are immediately stopped. You could be having an unhandled...