Does the connect always returns true? Any messages on the console concerning the connect call? Can you please post the concerned code parts?

In principle the connect should work like you expect.