I am trying to connect my socket of the Virtualbox, the server part in my virtual machine with phonegap, and is not working, What am I doing wrong? the connection must be TCP, where the customer is my Android application and my server is the computer. But it always gives the same error.
My error:
XMLHttpRequest cannot load https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_…168.1.111%3A10000/socket.io/%3FEIO%3D3%26transport%3Dpolling%26t%3DLGGA1OE. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.56.1:3000' is therefore not allowed access. The response had HTTP status code 503.
My controller in Android is this:
angular.module ( 'starter.controllers' [])
.controller ( 'DashCtrl', function ($ scope) {
console.log ( "tesssssssssssssssssssssssss");
var socket = io.connect ( '192.168.1.111:10000');
socket.emit ( "test", { "lat": 41, "long": -8});
})
My server is this:
def get_pressure_and_temperature (request_string):
JSON_OBJECT = json.loads (request_string)
print JSON_OBJECT
timestamp = timestamp # aux.get_date ()
hour = hour aux.get_time # ()
latitude = float (JSON_OBJECT [ "lat"])
longitude = float (JSON_OBJECT [ "long"])
pressure_temperature_result = pressure_temperature.build_data (timestamp, hour, latitude, longitude)
jresult = json.dumps (pressure_temperature_result)
return jresult
HOST = '# Symbolic name meaning all available interfaces
PORT = 10000 # Arbitrary non-privileged port
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
s.bind ((HOST, PORT))
s.listen (1)
while True:
conn, customer s.accept = ()
pid = os.fork ()
if pid == 0:
s.close ()
print 'Connected by' customer
#while True:
request_string = conn.recv (1024)
print "received," request_string
# Conn.send (get_pressure_and_temperature (request_string))
if not request_string: break
print "Finalizing connection with customer," customer
# Conn.close ()
sys.exit (0)
else:
conn.close ()