我正在尝试使用套接字连接到我在本地运行的Node服务器,但是我继续在'info - unhandled socket.io url'
服务器端+"XMLHttpRequest cannot load http://localhost:8080/socket.io/?EIO=3&transport=polling&t=1424356590540-0. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access."
在chrome上(使用address localhost:8000/index.html
)
// top six lines of code to see setup
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
io = require('socket.io').listen(server);
server.listen(8080);
我也在端口8000上使用python SimpleHTTPServer
客户代码是:
var socket = io.connect('http://localhost:8080');
socket.on('connection', function(){
console.log("connected")
});
使用https://cdn.socket.io/socket.io-1.3.4.js “版本的sockets.io
我假设html是不相关的,因为我没有任何javascript代码(对angular和jquery的引用除外)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句