nodejs NetworkError: 502

I have hosted an app on appfog.com. Its a chat program(I am a node beginner).

My app locally works perfect, but when I hosted, I am getting following error :

"NetworkError: 502 Bad Gateway - http://groupchat.aws.af.cm/socket.io/1/websocket/L3xe0Syb-sSf4ugVtHx-"

Firefox can't establish a connection to the server at ws://groupchat.aws.af.cm/socket.io/1/websocket/L3xe0Syb-sSf4ugVtHx-.

this.websocket = new Socket(this.prepareUrl() + query);

I am using this code in my index.html file:

<script src="http://groupchat.aws.af.cm/socket.io/socket.io.js"></script>
<script type="text/javascript" charset="utf-8">
    var socket = io.connect('http://groupchat.aws.af.cm');
</script>

Is my code wrong?

I had a similar problem with my node.js app hosted on AppFog. Make sure you do

io.set('transports', ['xhr-polling']);

It fixed it for me.