netty socket io CORS
node.js服务器
io.set('transports', ['websocket', 'xhr-polling', 'jsonp-polling', 'htmlfile', 'flashsocket']); io.set('origins', '*:*');
java 服务器
方式一:
Configuration config = new Configuration(); config.setTransports(Transport.POLLING, Transport.WEBSOCKET); config.setOrigin("*");
方式二:
Configuration config = new Configuration(); config.setOrigin("http://WebServerHost:WebServerPort"); // or http://domain.com
客户端:
var socket = io.connect('http://127.0.0.1:8081',{transports:['websocket','xhr-polling','jsonp-polling']});
ps: node.js 和java 1 都需要客户端做出设置,java 2 客户端无需设置
摘录连接:
https://stackoverflow.com/questions/30619436/netty-socket-io-cors-error-access-control-allow-origin
https://www.jianshu.com/p/1c966c74ac26
https://juejin.cn/s/netty-socketio%20cors