Accessing a Python server from Flash

I have a problem that has been breaking my head for over a week!
I have a Flash game that works under Python.
The game works fine from localhost, but doesn’t work if someone tries to play it from another computer. You can access mysql, login into the server, but can’t play.

When played from localhost the firestarter first gets an entry from 127.0.0.1:80 port, unknown service.

Then when the game starts the entry change to 127.0.0.1:2001, unknown service.

When other computer try to play, get a entry in 80 port, and stops there.

Below are some file excerpts.

config.py

mysql_host = 'localhost'

mysql_user = 'root'

mysql_pass = 'pass'

root_host = 'localhost'



policy_line = '<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy>

<site-control permitted-cross-domain-policies="all"/><allow-access-from domain="*" to-ports="843,2001,3001,4001,5001,6001,7001,8001,9001,9002,9092" />

</cross-domain-policy>'

init.py

from policy_server import PolicyFactory
from game_server import gameFactory
from twisted.internet import reactor
def main():

    print 'Server Started...'

    reactor.listenTCP(843, PolicyFactory())

    GameServer = GameFactory('localhost', 'pt_br')

    reactor.listenTCP(1024, gameServer)
    reactor.listenTCP(2001, gameServer)
    reactor.listenTCP(3001, gameServer)
    reactor.listenTCP(4001, gameServer)
    reactor.listenTCP(6001, gameServer)
    reactor.listenTCP(7001, gameServer)
    reactor.listenTCP(8001, gameServer)
    reactor.listenTCP(9001, gameServer)
    reactor.listenTCP(9002, gameServer)
    reactor.listenTCP(9092, gameServer)
    reactor.run()
if (__name__ == '__main__'):

    main()

crossdomain.xml

<cross-domain-policy><site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="localhost" to-ports="843,1024,2001,3001,4001,5001,6001,7001,8001,9001,9002,9092"/>
<allow-access-from domain="http://127.0.0.1" to-ports="843,1024,2001,3001,4001,5001,6001,7001,8001,9001,9002,9092"/>
</cross-domain-policy>

Answer

Well, looking at your configuration I would say you are not listening on your WAN IP but on localhost. So if you want other people to be able to use your application from another computer you need to make sure it’s listening on the WAN IP and that you do not have any firewalls in place that would prevent access to that IP.

On Ubuntu you can use ifconfig(might need to use sudo) and see what IP is given to your wlanX/ethX interface. That IP is your WAN IP.

Also, as suggested by Tom O’Connor, make sure you are not NATed on a home DSL line. If you are you will need to use port forwarding. Bear in mind that some ISP’s do not allow this for ports below 1024.

Attribution
Source : Link , Question Author : nmj77 , Answer Author : Lucas Kauffman

Leave a Comment