how to have two servers (django and node.js) in two different hosts and communicate to each other?

Viewed 781

I have a django app on openshift and can't add node.js cartridge to it because of this then I decide to create another app in another host like heroku. I want to write this in html in client side (in django openshift app ) :

.....
<script src="{% static 'social/js/socket.io.js' %}"></script>
<script>
    var socket = io.connect('mynodejs.herokuapp.com', {port: 4000});
</script>

and in server side do this (in heroku app):

var http = require('http');
var server = http.createServer().listen(4000);

I mean I want connect two app one in openshift(django) and one in heroku(for node.js server). but this doesn't work on node.js server(heroku) and that port(4000) doesn't really listen to requests coming. I search this problem and find this helpful link in SO.now I know that process.env.PORT is dynamically change every time node.js run the script. but I can't access to that with url. I means if process.env.PORT equals to 9048 then I can't access to :

mynodejs.herokuapp.com:9048

how to access to a port externally in heroku. is it possible ?

3 Answers
Related