在web中使用socket.io正常无比,到了electron就问题不断。一直报 xhr poll error。
首先做了如下尝试:
不使用require方式引入socket.io,使用文件路径方式引入socket.io-client.js。报错改为net-error,这个就是常见的https证书的问题。
然后查找资料,在启动时添加
app.commandLine.appendSwitch('ignore-certificate-errors');
即可忽略证书问题。
然后socket就连通了。