因此,我設置了一個ejabberd XMPP服務器,並使用nginx作爲EC2實例上的代理。 Strophe.js echobot示例可以從我的Chrome瀏覽器進行連接。這裏是請求頭:Spotify App Strophe.js無法連接到nginx/ejabberd組合
Request URL:http://foo.eu-west-1.compute.amazonaws.com/http-bind
Request Method:POST
Status Code:200 OK
Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:115
Content-Type:application/xml
Host:foo.compute.amazonaws.com
Origin:foo.eu-west-1.compute.amazonaws.com
Referer:foo.eu-west-1.compute.amazonaws.com/examples/echobot.html
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11
Request Payload
<body rid='2692151172' xmlns='http://jabber.org/protocol/httpbind' sid='15f6dc6cbc7a7d69b5db531c2ebf7828e094f043'/>
Response Headers
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Length:286
Content-Type:text/xml; charset=utf-8
Date:Fri, 04 Jan 2013 11:14:14 GMT
Server:nginx/1.2.4
我移植了echobot示例在Spotify中作爲應用程序工作。但是,Strophe無法連接。以下是Web Inspector網絡日誌:
Request URL:http://foo.eu-west-1.compute.amazonaws.com/http-bind
Request Headers
POST http://foo.eu-west-1.compute.amazonaws.com/http-bind HTTP/1.1
Origin: sp://chatify
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.15 Safari/535.11
Content-Type: application/xml
Request Payload
<body rid='790399813' xmlns='http://jabber.org/protocol/httpbind' to='ec2-54-246-45-111.eu-west-1.compute.amazonaws.com' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
現在。在manifest.json中看起來RequiredPermissons如下:
"RequiredPermissons": [
"http://foo.eu-west-1.compute.amazonaws.com",
"foo.eu-west-1.compute.amazonaws.com",
"http://foo.eu-west-1.compute.amazonaws.com/http-bind",
"foo.eu-west-1.compute.amazonaws.com/http-bind"
]
所以我覺得任何權限的工作,我可以加載foo.eu-west-1.compute.amazonaws.com來源。 Spotify應用程序使用不同的來源「sp:// chatify」。我讀到這可能會導致問題。並且Access-Control-Allow-Origin:*
應該被添加到標題中。我在nginx配置文件中這樣做是爲了發現它一直髮送。您可以在第一個請求的響應頭中看到它。
Strophe.js本身在本例中的日誌說,如果開啓:
error 0 happened
所以有什麼建議? 清單似乎是正確的 Access-Control-Allow-Origin; *似乎正確 它在瀏覽器中工作,但不是Spotify。
Thx爲您的幫助!
更新: 如果我在本地打開echobot.html,它仍然有效。起源於是null
。