Socket.io Android HTTPS - Connection Error xhr poll error

RMH*_*RMH 5 ssl https android node.js socket.io

I'm developing a chat application with HTTPS. This is the Socket.IO I've used

Server

First of all I developed the server with node.js and node module "socket.io": "^1.4.5"

In the server I have this:

var secure = {
  ca: fs.readFileSync('ca.pem'),
  key: fs.readFileSync('key.key'),
  cert: fs.readFileSync('cert.crt')
};

var server = https.createServer(secure, app);
var io = require('socket.io')(server);
Run Code Online (Sandbox Code Playgroud)

Clients

我用https://cdn.socket.io/socket.io-1.4.5.js开发了网站

我开发了 iOS 应用程序 pod 'Socket.IO-Client-Swift', '~> 5.5.0'

最后我正在开发 Android 应用程序

编译('io.socket:socket.io-client:0.7.0'){
  排除组:'org.json',模块:'json'
}

在网站和 iOS 应用程序中,我的 websocket 没有问题,但是当我尝试连接 Android 应用程序中的套接字时,我收到以下错误:

io.socket.engineio.client.EngineIOException:xhr 轮询错误

谢谢

bep*_*aya 0

这很可能是您使用服务器不接受的 ssl 套接字协议安装的 Android 版本的问题,反之亦然。

我相信情况是这样,因为我的 Android 4.4.4 也有同样的问题,但我的 5.1.1 平板电脑工作正常。

另一个例子是我们在 Spring 服务器上使用 OkHttpClient 看到了这个问题,我们必须扩展自己的 DelegateSSLSocket 来实现:

    @Override
    public void setEnabledProtocols(String[] protocols) {
        super.setEnabledProtocols(new String[]{TlsVersion.TLS_1_1.javaName()});
    }
Run Code Online (Sandbox Code Playgroud)

所以我认为这是一个非常相似的问题。无论如何,解决方法是将 Android 操作系统更新到 5.1.1。如果您在不更新 Android 操作系统的情况下找到其他方法,请告诉我!