What happens if you test with your server set to allow all IPs, does it work then? It may help track down if the issue is your code or the server.
Also it looks like you're using a different port to the defaults, the community server toolkit documentation does state:
"Currently, the server allows only server applications to connect using a direct socket connection on Port 1516. Before calling loginAsServerApp, you must call the setConnectivity method to set the connectivity. Once logged in, you can log out at any time by calling the logout method."