我有運行HTTPS的HTTPS服務器,由SSL保護的Java netty socket.io服務器和socket.io客戶端。netty socket io CORS錯誤:訪問控制 - 允許來源
在客戶端我已經如下因素代碼:
io.connect(url, {secure: true});
當我在瀏覽器中打開我的web服務器:https://127.0.0.1 我有以下錯誤:
socket.io-client:manager reconnect attempt error +1ms
socket.io.js (wiersz 1284)
socket.io-client:manager will wait 4000ms before reconnect attempt +1ms
socket.io.js (wiersz 1284)
engine.io-client:socket socket close with reason: "transport error" +3ms
socket.io.js (wiersz 3524)
engine.io-client:polling transport not open - deferring close +1ms
socket.io.js (wiersz 3524)
socket.io-client:manager attempting reconnect +4s
socket.io.js (wiersz 1284)
socket.io-client:manager readyState closed +3ms
socket.io.js (wiersz 1284)
socket.io-client:manager opening https://127.0.0.1:8080 +5ms
socket.io.js (wiersz 1284)
engine.io-client:socket creating transport "polling" +4s
socket.io.js (wiersz 3524)
engine.io-client:polling polling +5ms
socket.io.js (wiersz 3524)
engine.io-client:polling-xhr xhr poll +4ms
socket.io.js (wiersz 3524)
engine.io-client:polling-xhr xhr open GET: https://127.0.0.1:8080/socket.io/?EIO=3&transport=polling&t=1433329575886-4 +4ms
socket.io.js (wiersz 3524)
engine.io-client:polling-xhr xhr data null +6ms
socket.io.js (wiersz 3524)
GET https://127.0.0.1:8080/socket.io/? EIO=3&transport=polling&t=1433329575886-4
37ms
socket.io.js (wiersz 2739)
engine.io-client:socket setting transport polling +13ms
socket.io.js (wiersz 3524)
socket.io-client:manager connect attempt will timeout after 20000 +42ms
socket.io.js (wiersz 1284)
Zablokowano żądanie do zasobu innego pochodzenia: zasady „Same Origin Policy」 nie pozwalają wczytywać zdalnych zasobów z „https://127.0.0.1:8080/socket.io/?EIO=3&transport=polling&t=1433329575886- 4」. (nieudane żądanie CORS)
engine.io-client:socket socket error {"type":"TransportError","description":0} +151ms
socket.io.js (wiersz 3524)
socket.io-client:manager connect_error +145ms
我不知道這個錯誤的原因...這是錯誤的客戶端,服務器或JavaScript阻塞的東西?
我的錯誤是在拋光,但在英語中是這樣的:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8008/socket.io/1/?t=1399898337175. This can be fixed by moving the resource to the same domain or enabling CORS.
但我的資源是在同一個域。
你知道如何解決這個問題嗎? 我讀到,將「Access-Control-Allow-Origin」添加到標頭可以解決此問題。如何將它添加到netty java socket.io實現?
編輯:
我加入標題:訪問控制允許來源:「*」 和錯誤仍然出現