2016-04-13 12 views
0

仮想ボックスのソケットと私の仮想マシンのphonegapのサーバ部分を接続しようとしていますが、動作していません。接続はTCPでなければなりません。顧客は私のAndroidアプリケーションで、私のサーバはコンピュータです。しかし、常に同じエラーが発生します。ソケットをphonegapに接続しようとしています

マイエラー:

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.

アンドロイドで私のコントローラはこれです:

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}); 

}) 

私のサーバーはこれです:

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() 

答えて

0

私はこれがあなたの問題だと思う:

No 'Access-Control-Allow-Origin' header is present on the requested resource. 

私はあなたのアプリのためのいくつかの許可を最初に設定する必要があると思います。

そしておそらくサーバーからの返信でもあります。

私は自分でCordovaに取り組んでいます。そのため、最近のPhonegapの状態がわかりません。ここで

はあなたの助けと時間のチームメイトのために参考になっ

No 'Access-Control-Allow-Origin' header is present on the requested resource- AngularJS

no-access-control-allow-origin-header-is-present-on-the-requested-resource

+0

おかげかもしれない2つのリンクがあり、これが機能するかどうか、私が試してみて、表示されます –

関連する問題